steppermotor, PWM, Servo's

Ton
 
Posts: 22
Joined: Sun Nov 16, 2014 4:35 pm

steppermotor, PWM, Servo's

Wed Apr 29, 2015 7:42 pm

Hi,

I have been playing arond with the TIMER0 of the Vocore (RT5350). It is quite usable as a timer for various things. A servo driver is already available on Vonger's Blog, but now I have added some more drivers. It is operational, but I would like some beta testing to be done.

If anybody is interested, I can supply the code or make an image with the requested gpio pins for the devices.

This is a description of the features:
Code: Select all
TIMERALL

TimerAll uses TIMER0 of the RT5350 to time servos, PWM signals and Stepper motors.
Device parameters can be set through the /sys/class interface.
For example:
/sys/class/tadev/stepper1
/sys/class/tadev/PWM23
/sys/class/tadev/servo-rudder

All available gpio pins are configurable for any of these devices. Configuration is done in the Device Tree. (.dts file)
Devices can be mixed in any order. So Servos, PWM, and steppers, as long as there are free gpios.

Timer0 is a timer with a low priority, with the main clock and wifi having higher priority. This means that the signals have a small jitter.
This is visible the clearest with the Servos, which can wiggle a little bit. However, with a timeout this can be obfuscated.

Here a short overview of the functionality per type of device.

Servos:
- Servos will be clocked sequentally. So servo1 pulses, then servo2, then servo3 etc. This avoids peak currents in multiple servo systems
- Pulsewidth can be varied between 0,5 and 2,5 ms
- Pulsewidth can be set to 0, then there is no pulse; the servo is not driven
- Max pulsewidth and min pulsewidth can be set. The servo can not be driven outside these values. Useful as an extra safety for servos that are mechanically restricted
- A timeout value can be set. This is the time that the pulse is maintained, and after expiration, the servo is not driven anymore. This saves energy
- A synchronised motion can be set, which moves to a specified target within the specified time

Commands:
echo X > pulsewidth       50 < X < 250   unit is 10us
echo X > min_pulsewidth    50 < X < 250   unit is 10us
echo X > max_pulsewidth    50 < X < 250   unit is 10us
echo X > timout        0 < X < 60000 unit is 1ms
echo X Y > sync      500 < X < 10000 unit is 1ms, 50 < Y < 250 unit is 10us. (Move to position Y in X time)
 

PWM:
- The frequency of the signal is approximately 400Hz
- The outputsignal can have a duty_cycle between 0 and 255.
- 0 means output is always 0, 255 means output is always 1.
- A value of 128 would mean a 400Hz square wave with a 50% duty_cycle
- A synchronised change of duty_cycle can be set, which changes the duty_cycle to a specified target-value within the specified time    

Commands:
echo X > duty_cycle        0 < X < 255
echo X Y > sync      500 < X < 10000 unit is 1ms, 0 < Y < 255. (set duty_cycle to Y in X time)


Stepper:
- 4 gpios can be assigned to the 4 phases
- A half step sequence is used
- Position of the stepper is saved
- A target can be given, and then the number of steps and direction are calculated
- A lineair velocity profile is used. That means the motor starts up slowly, and decelerates to zero at target.
- When a target is specified while the motor is running, the Lineair velocity profile is maintained. This means no abrupt speedchanges.
- A timeout value can be given, which sets the time the coils stay activated after motion.

Commands:
echo X > target           X  32bit int
echo X > timout       0 < X < 60000 unit is 1ms


Vonger
 
Posts: 896
Joined: Sun Oct 19, 2014 6:00 am

Re: steppermotor, PWM, Servo's

Sat May 02, 2015 12:53 pm

Please share, I want to try :) Thank you!

Ton
 
Posts: 22
Joined: Sun Nov 16, 2014 4:35 pm

Re: steppermotor, PWM, Servo's

Mon May 18, 2015 7:29 pm

Ok, took me a while to respond, but I have added a rar file with:
- sources and build instructions
- DTS file that sets up one stepper, one PWM and two servo's

stepper on gpios 1 2 3 4
pwm on gpio 21
servo1 on gpio 17
servo2 on gpio 20

I also have a built image available for easy testing. But this site has a maximum of 2MB for a attachment, so I can not upload it here.
Feel free to ask me to send it to you
Attachments
Timerall.rar
(21.23 KiB) Downloaded 479 times

Return to VoCore & VoCore+Dock

Who is online

Users browsing this forum: No registered users and 28 guests