Servo and Background PWM on 14m2

johndo

Member
Hi All... Its been a while since i've posted but have lurked now and then. Anyway, at the moment I'm designing an active laser beam postioner for a laser perimeter fence alarm using three servos in a triangular configuration to move the laser around. It does not have to be super fast but just able to stop the laser beam from going out of alignment. I need to have background PWM to pulse the laser diode to connect with a 38khz receiver. Am I able to control 3 servos using ADC for feedback AND do background PWM on the one chip. I know that certain pins share the same timer (C.0 and C.2) as the servos. Could someone explain really simply (for me the dummy) on how to acheive this. Or would it be easier to do PWM and SERVO on two separate chips. Thanks for your time...
 

johndo

Member
Hi Erco,

I'm using one of these SFH 5410-38-Z with a 650nm laser diode for ease of alignment. A little bit out of the ir range but works fine. I guess my question is can i have continuous background PWM and control three servos on the same chip (14m2). This is my setup atm.

Outputs B.3, B.4, B.5 connected to servos and C.0 or C.2 for PWM. I have tried HPWM thinking that it uses a different timer.No good! When the servos move the PWM stops and starts. I'm just not getting it!

Wow! Just saw your Blaster Bot great job!
 
Last edited:

johndo

Member
Just to add some more information, I have also tried using Outputs B.0 , B.1 and B.3 for the servo's as these dont appear to have PWM attached to them. Still with the same result.

The big deal with this project is that I need continuous PWM with no glitches or that drops the output of the receiver to logic low and triggers the alarm. And this needs to happen with 3 servos working occasionally on the same 14m2. Is this possible.

Kurt
 

tony_g

Senior Member
im not sure if this suggestion would work 100% without a lot of fine tuning but have you looked at using the parallel task capabilities?

its not true multitasking but i have found on some projects that it can be very usefull to a degree if you dont mind spending some time on adjusting and fine tuning your code in gradual steps as you experiment with different ways to get it working efficiently.

tony
 

hippy

Technical Support
Staff member
On the 14M2 it should be possible to have servos operating and use background PWMOUT on B.2 and/or B.4.
 

johndo

Member
Thanks Tony and Hippy.... I will definately look into the parallel task's Tony.

Hippy - So only Port B will work with servos therefore Outputs B.0, B.1, B,3, B.5 for servos and B.4 or B.2 for continuous background 38khz PWM?

Could you briefly explain why this would work. I am a bit thick so i would really like to understand why...Will give it a try tomorrow anyway.

Thanks again for your help everyone....Cheers, Kurt
 

hippy

Technical Support
Staff member
Hippy - So only Port B will work with servos therefore Outputs B.0, B.1, B,3, B.5 for servos and B.4 or B.2 for continuous background 38khz PWM?
Correct. Though you can use B.2 or B.4 for servos if not being used for PWM.

So servos on B.0, B.1 and B.2 with PWMOUT on B.4 should work.

Could you briefly explain why this would work.
The servos and PWMOUT on C.0 and C.2 share the same timer so you cannot have those both operating at the same time.

PWMOUT on B.2 and B.4 use a different timer so they can be used while using servos.
 

johndo

Member
Hippy...Thank you so much for explaining that in simple language. Told you I was a bit thick ;-)

Back to the Diptrace drawing board I go!!! And thanks to everyone also for their input...Kurt
 

johndo

Member
I am happy to report all is good with my 14m2. Have servos working on B.1, B.3 and B.5 with continuous 38khz PWM on B.2. I just needed a litte nudge in understanding what was stated in the manual. Must have had a mental block or something.

Thanks again...
 
Top