PlainDSP

plaindsp_audio_kit_s
The huge popularity of PlainDSP (merge of PlainFFT and PlainADC libraries) and the numerous requests for help drove me to think about a convenient solution for all designers, artists, students, professors, R&D people, prototypists who need to understand, experiment, create systems which feature advanced Digital Signal Processing on Arduino. The result of intense thoughts, design and writing is the collection PlainDSP kits, starting with the audio kit.

So please, pay a visit to plaindsp web site. By getting one of these kits you not only get a desirable product you also support a private initiative for popularizing science. Thank you.

 

Arduino on French/German TV

Arduino on French (and German) TV, Arte channel: watch the Future program and enjoy!

Here are a few ideas that I picked up in the presentation:

  • Floriane: “It is fun when it works!”
  • David Cuartielles: Has fun discovering that the makers are ahead of his own imagination
  • It is good to see Arduino entering the conventional education system. However, the working conditions stay the same: two mates sitting at one table and facing the wall. Flip the chairs, tilt the screen and use large, open space tables!
  • Sailing boat driven by Arduino: awesome, however a little bit more expensive than 20€! The meta arduino components can be very expensive!
  • Bye bye Popy, see you at QuaiLab!

arte_arduino

News from the Plain DSP planet

You may like read this interesting paper dedicated to the use of the different types of memory available from an Arduino Board .

Next is a picture from a cousin microcontroller of the ATMEGA328, which illustrates the various areas dedicated to each main function of the microcontroller such as the memories.

atmel-ATmega8-8-bit-controller-die-shot

Credit: ZeptoBars

HTH

Stepper Motors (Part 4)

Part 12, 3, 4

Speed management

As seen in the previous posts,torques must be taken into account while setting the rotor speed during the acceleration, steady and deceleration phases. Starting from there, we have two options: the theoretical and the experimental approaches. Although playing with physics and maths might be fun, it is probably quicker and more efficient to go the experimental way.

Under loaded conditions, let’s firstly estimate the starting speed using at pretty low frequency  such as 50/100Hz. Then increase the frequency up to the point where the rotor can no longer cope with the driving wave. Now that we know the limits, all we have to do is to program a ramping process. The following sketch illustrates a simple routine which accelerates and decelerates the rotor speed automatically.

uint8_t _stepPinMask = (1 << PINB5);
uint8_t _dirPinMask = (1 << PINB4);
const uint16_t _pulsesPerRound = 48; /* As per motor specifications */
const uint16_t _pulseWMax = 15000;
const uint16_t _pulseWMin = 5000;
const uint16_t _pulseWSteps = 500;

void setup(void)
{ 
	/* Initialize ports */
	DDRB |= _stepPinMask;
	DDRB |= _dirPinMask;
}


void loop(void)
{
	Rotate(48 << 2, 1);
	Rotate(48 << 2, 0);
}


inline void Pulse(uint16_t pulseWidth) 
{
	PORTB |= _stepPinMask;
	delayMicroseconds(2);
	PORTB &=  ~_stepPinMask;
	if (pulseWidth < 16000) {
		delayMicroseconds(pulseWidth);
	} else {
		delay(pulseWidth / 1000);
	}
}


void Rotate(uint16_t steps, uint8_t direction) 
{
	/* Set direction */
	if (direction) {
		PORTB |= _dirPinMask;	
	} else {
		PORTB &= ~_dirPinMask;
	}
	uint16_t rampsSteps = ((_pulseWMax - _pulseWMin) / _pulseWSteps);
	/* Constrain the number of ramp steps to the whole number of steps */
	if (rampsSteps > steps) {
		rampsSteps = (steps >> 1);
	}
	/* Compute the number of steps at constant speed */
	uint16_t constSpeedSteps = (steps - (rampsSteps << 1));
	uint16_t pulseW = _pulseWMax;
	/* Acceleration phase */
	for (uint16_t i = 0; i < rampsSteps; i++) {
		Pulse(pulseW);
		pulseW -= _pulseWSteps; /* Decrease pulse width */
	}
	/* Constant speed phase */
	for (uint16_t i = 0; i < constSpeedSteps; i++) {
		Pulse(pulseW);
	}
	/* Deceleration phase */
	for (uint16_t i = 0; i < rampsSteps; i++) {
		Pulse(pulseW);
		pulseW += _pulseWSteps; /* Increase pulse width */
	}
}

Note that the pulsing engine has been taken apart in an online routine in order to ease the readability of the code. In the same manner, the maximum, minimum and step pulse width are set in global constants.

It is interesting to compare the effects of both the constant speed operation and the accelerated and decelerated operations on the torque applied to the motor while starting, stopping or changing directions. The instantaneous torque reduction might be very useful for reducing the instantaneous stress applied to the belt if such an accessory is attached to the motor via a timing belt pulley. The counterpart of this improvement is some noise at lower excitation frequencies.

[HOWTO] PlainDSP audio shield: M2M Communication system

The Critical Tinkers team recently achieved an amazing application based on the plaindsp kit. The M2M protocol they developed provides a smart way to send information to an Arduino board using a plaindsp audio shield from any sound emitting device (e.g. a cell phone). Next video is a teaser which demonstrates the principle of operation, as long as your computer is not muted !

Learn much more about this M2M communication application from plaindsp.com

Stepper Motors (Part 3)

Part 12, 3, 4

A4988 module

Let’s go into the details of this module through the understanding of its pinout:

pololu_3

The suggested basic wiring is as follows:

pololu_4

  • ~ENABLE: GND
  • MS1, 2 & 3: GND
  • ~RESET connected to ~SLEEP
  • STEP: step pulse
  • DIR: rotational direction
  • GND: same GND for VDD and VMOT
  • VDD: 3.3V to 5V
  • 1A,1B: winding 1
  • 2A, 2B: winding 2
  • VMOT: as per stepper motor specifications

Note: the ~ spanish tilde is used for negating a bit value in C ((~0 | 1) == 1); this sign is also used in Ki

Step pulses must simply comply with the required pulse width as per the A4988 datasheet.

pololu_5

The nice thing about this driver is that you do not have to care about the duty cycle of the step pulse signal. On the other hand, care shall be taken about choosing the appropriate frequency so that it fits the stepper motor requirements (Check the “Torque” paragraph in Part 1). There is no danger at all at using innapropriate frequency. If the frequency is too high, the rotor will erratically move or not move at all. If the frequency is too low, the rotor will move in rough steps and generate a growling sound.

Next is a code sample for running the A4988 module in a basic way:

uint8_t _stepPinMask = (1 << PINB5);
uint8_t _dirPinMask = (1 << PINB4);
uint16_t _pulsesPerRound = 48; /* As per the stepper motor specifications */

void setup(void)
{ 
	/* Initialize ports */
	DDRB |= _stepPinMask;
	DDRB |= _dirPinMask;
}


void loop(void)
{
	/* Rotate motor back and forth */
	Rotate(_pulsesPerRound << 1, 1, 5000);
	Rotate(_pulsesPerRound << 1, 0, 5000);
}


void Rotate(uint16_t steps, uint8_t direction, uint16_t pulseWidth) 
{
	if (direction) {
		PORTB |= _dirPinMask;	
	} else {
		PORTB &= ~_dirPinMask;
	}
	for (uint16_t i = 0; i < steps; i++) {
		/* Generate a step pulse. The pulse width is expressed in microseconds  
		The on state is twice the minimum requirement and it is insignificant 
		versus the off time which is mainly responsible for the frequency 
		setting */
		PORTB |= _stepPinMask;
		delayMicroseconds(2);
		PORTB &=  ~_stepPinMask;
		/* Use the most appropriate delay function */
		if (pulseWidth < 16000) {
			delayMicroseconds(pulseWidth);
		} else {
			delay(pulseWidth / 1000);
		}
	}
}

 

Next post on same subject

Stepper Motors (Part 2)

Part 12, 3, 4

Stepper motor drivers

These electronic devices are the interface between the stepper motor and the controller (e.g. Micro-controller, computer, etc.). Here is a short recap of the expected requirements for such an interface:

  • Drive Unipolar and/or Bipolar motors
  • Convert step commands into appropriate waveforms applied to the motor coils
  • Set direction (cw / ccw)
  • Use separate voltages for digital command and motor supply

In addition to these mandatory requirements, we may enumerate (highly) desirable requirements:

  • Over current protection
  • Over temperature protection
  • Open circuit or short circuit protection
  • Microstepping
  • Low power dissipation

Unipolar or bipolar?

The first decision to be made depends upon the type of stepper motor to be driven. Next pictures illustrate in an other simplified manner the two types of motors and the principle of operation of their related drivers:

Unipolar configuration

The term unipolar means that the current flowing through each winding always goes in the same direction.

g3870

Advantages

  • Simple electronics

Drawbacks

  • More complex wiring, higher cost of motor production
  • Lower motor size/torque ratio, as only 1 coil out of 4 is used for each angle displacement.

Bipolar configuration

In the bipolar configuration, the current flowing through each winding goes in both directions (H-bridges).

g3436

Advantages

  • Simple wiring, lower cost of motor production
  • Better motor size/torque ratio, as 1 coil out of 2 is used for each angle displacement.

Drawbacks

  • Much more complex electronics (H-bridge configuration)

Discrete or integrated design?

Based on the above requirements, the second decision to be made is: shall be build a discrete components based module or use an integrated module? Well, from the point of view of size, efficiency, performances and cost, integrated solutions are the most attractive option. This drove me to scan the available options, including the modules in use in most early 3D printers.

This module is based on the Allegro A4988 chip which is a highly integrated circuit containing all the enumerated requirements in a tiny package.

ET-QFN-with-exposed-pad-28-lead

The component information is available from here and the  data sheet available from here. Multiple implementation of this component exist. The most popular module has been designed by Pololu and it is available from their site

  0J4576.1200

 

The 2 banks of 8 pins make this module easy to plug on a bread board or on most 3D printers or CNC mainboards. From the picture above, we can observe the sub-miniature trim pot used for setting the trip point for triggering an overcurrent condition. These modules are available from many places at variable prices, always below 5€. The few ones that I bought on eBay came assembled in an antistatic package  containing an optional dissipator.

pololu_1

Here is an example of use of the module which is plugged on the breadboard from an arduino proto shield:

pololu_2

In its most simple configuration, the wiring is very simple

bipolar_step_mot

The only additional component is a 100µF capacitor used for filtering transient voltages. the A4988 can also drive unipolar stepper motors as shown below

unipolar_step_mot

Next post on same subject

Stepper Motors (Part 1)

Part 12, 3, 4

The development and use of stepper motors is directly related to the development of digital electronics. Early systems featuring stepper motors were requiring quite complex electronics made of gates, counters, buffers and voltage interfaces. In the late 70’s I contributed to the automation of a soldering machine for tunnel diode silicon chips. Square silicon chips were picked up from a container placed on a XY tray. Engineers from SESCOSEM had a hard time deciding about the technology to be used for the XY tray drive: analog + indexing system or stepper motor? At this time, the size of the required stepper motors was the main limiting factor. Nowadays they would have probably prefered a stepper motor, such as the very popular NEMA17 series stepper motors in use in many low cost 3D printers

4018_High_Torque_Stepper_P

The aim of this paper is not to describe the principle of operation of stepper motors. Many web sites did that very well before with plenty illustrations and animations. Using your favorite web search engine will inevitably drive you to many interesting places. However, let’s recap the main properties from these special types of motors.

Torque

muscle

This is an indication of how muscled is one motor. In principle, this is the most critical parameter to be taken into account. How much N.m do we need to drive our application? This is quite a complex task which involves lots of calculations and a bit of intuition and experience when addressing the safety margin question. If the objective is just to play around with a stepper motor, any motor will fit. If this motor must drive pretty heavy loads and break friction resistance, torque might become critical.

Note: Stepper motors behave very differently from all other electrical motors, leading to the need for defining torque related terms such as:

  • Holding Torque: amount of torque that the motor produces when it has rated current flowing through the windings but the motor is at rest.
  • Detent Torque: amount of torque that the motor produces when it is not energized. No current is flowing through the windings.
  • Pull-in Torque Curve: Shows the maximum value of torque at given speeds that the motor can start, stop or reverse. The motor cannot start at a speed that is beyond this curve. It also cannot instantly reverse or stop with any accuracy at a point beyond this curve.
  • Stop / Start Region: Area on and underneath the pull-in curve. For any load value in this region, the motor can start, stop, or reverse “instantly” (no ramping required) at the corresponding speed value.
  • Pull-out Torque Curve: Shows the maximum value of torque at given speeds that the motor can generate while running in synchronism. If the motor is run outside of this curve, it will stall.
  • Slew Range: the area between the pull-in and the pull-out curves, where to maintain synchronism, the motor speed must be ramped (adjusted gradually).

Angular resolution

angles

This is an indication of how little can be the angular each single displacement of the shaft. This value is always a fraction of 360′ and it usually ranges from few degrees down to fractions of a degree (e.g. 3.6, 1.8, 0.9, 0.45 degree). Trivial enough, the number of steps per revolution depends on the angular resolution (e.g. a 1.8 angular resolution leads to 200 steps/rev).

Note: Thanks to adequate excitation of winding coils, some stepper motor drivers can set sub resolution angles (1/2, 1/4, 1/8 and 1/16 angle), known as microsteps.

Size

size

Stepper motors exist in many different sizes. However, some standardization exist, such as the NEMA. NEMA 08, 11, 14, 16, 17, 23, 24, 34 42 and 52 stand for the size of the front mounting plate of the motor: 20mm, 28mm, 35mm, 39mm, 42mm, 57mm, 60mm, 86mm, 110mm and 130mm respectively. Then take care about the length of the motor, and also about the diameter and length of the shaft.

Internal wiring

g4030

There are mainly two types of internal wirings easily recognizable thanks to the number of supply leads.

  • Bipolar motors require only 2 pairs of leads.
  • Unipolar motors require 2 times 3 leads.

Note: A driver for bipolar motors will also be able to drive a 6 leads unipolar motor. The only required modification consists is NOT connecting the common connection. On the other hand, a driver for unipolar motors will NOT be able to drive bipolar motors. This subject shall be covered in more details in the next coming posts.

Phase resistance

This is the ohmic value for each winding, it may vary from tens of ohm to tenths of ohm. This resistance must be taken into account when selecting the appropriate driver. Depending upon the supply voltage, the resulting current may vary from hundreds of milliamps to amps. This is real power!

Next post on same subject

Blog of the Day

A robot which helps.

At first glance, this balancing robots looks like “just an other balancing robot”, except that the control is expected to be pretty complex for  “just an other balancing robot”. Watching the attached video almost immediately changed my mind: this robot looks like the ultimate helper for carrying things that you cannot manage on your own for various reasons: too heavy, too large, too fragile, etc.

Read “A Robot That Balances on a Ball”

Watch the video

Tips and Tricks (Part 20)

Previous tip and trick

Acquiring data is great, sending data away is even greater. In this way, all sorts of physical measurements can be remotely read in order to capture events, record signals, trigger alarms, etc.

More and more communication solutions exist, each of them having their advantages and drawbacks. The aim of this post is not to provide an exhaustive list of them. However, let’s mention the most popular devices and protocols from the Arduino planet:

  • Xbee/ZigBee: versatile, pretty low power, from cheap to costly
  • RF12: cheap, low power, limited range and functions
  • GSM/GPRS: almost universal, power greedy, expensive

The Xbee modules have a very particular foot print which features 2x 10 pins with 2mm spaces. Many makers addressed the need for Arduino compatible shields, including the Arduino team it self (Check this thread). This particular shield features a sliding switch which allows the user to manage data exchanged between the Xbee module and the micro controller unit (MCU) or the USB cable.

switch1 switch2

But the principle of sharing Rx Tx lines from Arduino has strong limitations, mainly when you need to upload code to the Arduino board, while the shield and the Xbee module are attached to it.

Here is a very easy (almost trivial) trick which will release some of your stress. The idea is to leave the Rx Tx pins in peace with the MCU while applying no non-reversible changes to the electronics or PCB from the shield. This is how:

Take an Arduino board

UNO

Slightly bend the Rx Tx pins from the shield so that they no longer get into the Arduino board socket

shield_pins

Plug the shield on the Arduino board

assembly_pin_in_a

Place one jumper between Rx pin and digital pin 2 and one jumper between Tx pin and digital pin 3

jumpers1

Instead of using the commands from the Serial library, use the commands from any soft serial library (This one for example) and link the pin 2 and 3 to the receive and send pins.

#include <SoftwareSerial.h> // Include library
SoftwareSerial mySerial(2, 3); // Create object and declare Rx and Tx pins

void setup()  
{
    mySerial.begin(9600); // initialize comm port
}

void loop(void)
{
    mySerial.println("AT"); // Send any instruction to the comm port
    while(true); // Run once
}

That’s all! Under these conditions, the shield will perform as before and blink as it should. In addition, you re now free to use the Serial commands for debugging your application.

HTH