Fischertechnik with Arduino

Of course, there exist some other [1] [2] blog articles in the downs of the Internet discussing how to control Fischertechnik scenarios with an Arduino. The aim of this article is to give the reader some hands-on information how to setup a very simple scenario as a starting point for own solutions. It should be easy to follow the schematics below. More compilcated ones may follow in future.

I take no liability for the presented schematics. It’s provided as is and you rebuild it on your own risk.

In the figures below you can see a simple merry-go-round. It has a standard 9v motor and is supplied with a battery package.

The motor and the arduino

The motor and the arduino

The merry-go-round. You can see the connection between the Fischertechnik wires and standard jumper wires

The merry-go-round. You can see the connection between the Fischertechnik wires and standard jumper wires

Top view

Top view

The arduino and all the wiring

The arduino and all the wiring

Basically all what you need is to follow the zoetrope example from the arduino starter kit and exchange the motor with the Fischertechnik motor. This is the black box on the merry-go-round.

On the breadboard there is a push button for start and stop, and a second to toggle the direction. With a pot you can adjust the speed. The only thing you really need to work out is to connect the Fischertechnik connectors on the red and the green cable with a thin connector normally used for ground and +5v (black and red).

The code is here (thanks to Scott Fitzgerald no one needs to hack down the examples by hand):


/*
Arduino Starter Kit example
Project 10 - Zoetrope

This sketch is written to accompany Project 10 in the
Arduino Starter Kit

Parts required:
two 10 kilohm resistors
2 momentary pushbuttons
one 10 kilohm potentiometer
motor
9V battery
H-Bridge

Created 13 September 2012
by Scott Fitzgerald
Thanks to Federico Vanzati for improvements

http://arduino.cc/starterKit

This example code is part of the public domain
*/

const int controlPin1 = 2; // connected to pin 7 on the H-bridge
const int controlPin2 = 3; // connected to pin 2 on the H-bridge
const int enablePin = 9; // connected to pin 1 on the H-bridge
const int directionSwitchPin = 4; // connected to the switch for direction
const int onOffSwitchStateSwitchPin = 5; // connected to the switch for turning the motor on and off
const int potPin = A0; // connected to the potentiometer's output

// create some variables to hold values from your inputs
int onOffSwitchState = 0; // current state of the On/Off switch
int previousOnOffSwitchState = 0; // previous position of the on/off switch
int directionSwitchState = 0; // current state of the direction switch
int previousDirectionSwitchState = 0; // previous state of the direction switch

int motorEnabled = 0; // Turns the motor on/off
int motorSpeed = 0; // speed of the motor
int motorDirection = 1; // current direction of the motor

void setup(){
// intialize the inputs and outputs
pinMode(directionSwitchPin, INPUT);
pinMode(onOffSwitchStateSwitchPin, INPUT);
pinMode(controlPin1, OUTPUT);
pinMode(controlPin2, OUTPUT);
pinMode(enablePin, OUTPUT);

// pull the enable pin LOW to start
digitalWrite(enablePin, LOW);
}

void loop(){
// read the value of the on/off switch
onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
delay(1);

// read the value of the direction switch
directionSwitchState = digitalRead(directionSwitchPin);

// read the value of the pot and divide by 4 to get
// a value that can be used for PWM
motorSpeed = analogRead(potPin)/4;
// if the on/off button changed state since the last loop()
if(onOffSwitchState != previousOnOffSwitchState){
// change the value of motorEnabled if pressed
if(onOffSwitchState == HIGH){
motorEnabled = !motorEnabled;
}
}

// if the direction button changed state since the last loop()
if (directionSwitchState != previousDirectionSwitchState) {
// change the value of motorDirection if pressed
if (directionSwitchState == HIGH) {
motorDirection = !motorDirection;
}
}

// change the direction the motor spins by talking
// to the control pins on the H-Bridge
if (motorDirection == 1) {
digitalWrite(controlPin1, HIGH);
digitalWrite(controlPin2, LOW);
}
else {
digitalWrite(controlPin1, LOW);
digitalWrite(controlPin2, HIGH);
}

// if the motor is supposed to be on
if (motorEnabled == 1) {
// PWM the enable pin to vary the speed
analogWrite(enablePin, motorSpeed);
}
else { // if the motor is not supposed to be on
//turn the motor off
analogWrite(enablePin, 0);
}
// save the current On/Offswitch state as the previous
previousDirectionSwitchState = directionSwitchState;
// save the current switch state as the previous
previousOnOffSwitchState = onOffSwitchState;
}

Below you can find the wiring as a picture exported from Fritzing.

DC_motor_control_Steckplatine

Following parts were used:

Fischertechnik:
- Super Fun Park, Part ID 508775

control devices:
- 1 Arduino Uno R3 board
- 1 USB cable
- 1 Breadboard
- 1 L293DNE (N for DIL package and E for eco/RoHS compliant) IC for motor control

basic components:
- 1 10K Ohm pot (for speed control)
- 2 10K Ohm resistors (pull-down)
- 2 momentary switches (start/stop and forward/backward)

wires:
- 4 green jumper wires
- 3 yellow jumper wires
- 2 long red jumper wires (+5v)
- 1 long flexible wire (+5v)
- 3 short red jumper wires (+5v)
- 2 long black jumper wires (ground)
- 2 short black jumper wires (ground)
- 1 long flexible wire (ground)

The next days I will do some more fancy stuff: Acquiring data and control from remote…

Posted in Embedded, Post | 1 Comment

Arduino

20 Years after my last serious interaction with electronics at school I’ve been come out of the cold dark into the warm light of physical computing of these days and bought 2 weeks ago the arduino starter kit. This is the most complete arduino kit with a board, a LCD, optocouplers, motor IC, wires, temperature sensors and alike. Very good starting point, though some figures in the enclosed book aren’t exactly what needs to be done. But with some good thoughts anybody interested in electronics could manage these pitfalls. What I’ve really enjoyed was the zoetrope.

What I wanna like to do here is  to outline two points: First at all some good books and resources for the electronic enthusiast and second to present a solution to control some good old Fischertechnik stuff here, much cheaper as it is envisaged by Fischertechnik itself with their controller. This is a well equiped controller based on a 200 MHz ARM processor and all inputs are safed against overvoltage. Anyway, the price of about 200€ (and the power supply from Fischertechnik is also about 60€ which needs to be acquired separately) is a bit high.With an arduino this could come at a much lower rate (roughly a third of the price). It’s pretty simple to setup a motor control with the Arduino, so I will provide the respective information in a second article.

Books on Electronics:

A very exciting book and really hands-on in its best sense is Make: Electronics, Charles Platt, 2009. Anybody who feels a bit uncomfortable with the handling of a multimeter or with a soldering rod: this book is for you!

A book much more affiliated with the theoretical basics of electronics is the book Practical Electronics for Inventors, 2000, McGrawHill from Paul Scherz. It’s very accessable and gives the reader not just the mathematical stuff at hand, but rather describes important circuits, symbols and all the stuff to start off with real world electronic projects. This is a must have for every serious electronic enthusiast. There exist also a newer second edition with Simon Monk.

A very nice book in german is the book from Erik Bartmann, Die elektronische Welt mit Arduino entdecken, O’Reilly, 2011. It’s a book in a very hans-on manner. Though, there exist a tremendous number of typos within the text. It is intended for electronics newbies and describes all the components needed for doing some cool stuff. It starts with very easy projects and end up in self built LEGO robots. Part of the book is the description of the Processing language.

Another excellent resource is the Arduino Projects book (coming together with the Arduino Starter kit). A 170 pages long book with description of 15 projects. It is written in a readable manner and don’t take too deep assumptions about the abilities of the ongoing hardware hacker.

Free available is also the documentation of the Starter Kit by Earthshine Electronics. It has rather a focus on LEDs, but is also very readable and a good starting point for anybody interested in Arduinos.

Another good starting point to get familiar with Arduino is also the documentation from SparkFun to their Inventor’s Kit for Arduino.

Resources on the Internet:

http://www.adafruit.com/, A company located at the heart of NYC which builds cool shields. It is headed by lady Ada. Most interesting is the huge learning center of free accessable introductions to build nice DIY devices: http://learn.adafruit.com/

A good account on soldering can you find on the ladyada web site.

Best prices for any kind of electronic prices you can find for instance on http://de.farnell.com. For MCUs, CPUs and FPUs special rates are offered for multiple orders of the same product ID.

At the batronix web site you can find best prizes for oscilloscopes.

A very good account on all topics around microcontrollers can be found  in german on: http://www.mikrocontroller.net.

All the microprocessors used on Arduino boards are provided by Atmel, one of the major players of low level microcontrollers: http://www.atmel.com/. Most of interest are of course the 8-bit processors, but they also provide 32-bit and very special purpose chips.

Another vendor of microprocessors (in Europe located) is ST Microelectronics: http://www.st.com/web/en/home.html.

A talented physical computing maker is Jack Eisenmann. He has built an AVR-based 8-bit parallel computer based on 16 ATMEGA328-PU. He has some interesting descriptions and a video with a delicious 8-bit sound online: http://www.ostracodfiles.com/mega/menu.html.

The description of the Fischertechnik stuff will follow in a second article.

 

Posted in Post | Leave a comment