Reversing pwmout

Bond

New Member
With the 08m2 is there an easy way to make a pmw reversa as it only has 1 pmw port do you use that for the input or output & how easy is it to reversa the signal
 

hippy

Ex-Staff (retired)
How do you mean by reversing the PWM signal ?

Perhaps an illustration or example of why you would need this capability or how it would be used would help members answer the question.
 

Bond

New Member
Signal from rc receiver to servo it works in one direction. signal from rc receiver to 08m2 and the servo works in the opposite direction
 

nick12ab

Senior Member
Signal from rc receiver to servo it works in one direction. signal from rc receiver to 08m2 and the servo works in the opposite direction
This is still not clear.

Does a certain component require that you output a PWM signal then turn the pin into an input to receive data from it?

Do you want to control something via PWM and control a servo at the same time? If you have another pin (which does not need to be a PWM pin) then you can use the servo command to control the servo.
 

Jeremy Harris

Senior Member
It seems to me (and I may have misunderstood) that you could be confusing two commands and their functions. Servos are inherently reversible and the SERVO command allows bidirectional movement by default.

If you are trying to drive a motor at a variable speed using the PWMOUT command, together with a suitable motor driver, then you need to use another pin and some additional circuitry to set the motor direction, as this will require the polarity of the motor to be switched in order to change the motor direction.

You can use the SERVO command to control an RC motor speed controller directly, and if you use a bidirectional motor speed controller, like those used in RC boats and cars, then the SERVO command can be used to make the motor run forwards or backwards at a variable speed.
 

rossko57

Senior Member
My read is that he wants to use the Picaxe as a servo-type device, i.e. listening to a PWM servo drive signal from a r/c reciever (and doing whatever in response). Sounds like a job for PULSIN
 

Bond

New Member
All I wish to do is using a y lead from my reciever to have one server operate as normal the other servo (somehow through the 08m2) work in the opposite direction so that when the 2 servos face each other they work actually the same way

Not sure if I should use the inputs or the pwm to achive this or how I would swap the signal around so the second servo was reversed

I hope this is clearer
 

jojojo

Senior Member
So, two servo's synchronized, but in opposite direction.
OK.

Why do you want use PWM ?

SERVO can do that, whithout any problem.

Bye.
 

Haku

Senior Member
If you want a y-lead servo reverser then there are commercially available ones that can probably do the job much better than an 08m2, and you wouldn't have to program it.
 

BeanieBots

Moderator
You can reverse a servo by swapping over the leads to both the motor and the POT.
You can take the drive from the other end of the servo horn.
You can mount it upside down.

If you want to take the 08M2 route, then it's just a bit of maths.
Assuming your servo will be working in the range 75 - 225 then simply subtract the value for the first servo from 300 and it will give you the value for the second.

example:-
first servo demand is 75 so second needs to be at 225
300 - 75 = 225

first servo demand is 225 so second servo needs to be at 75
300 - 225 = 75

first servo is at neutral (150) so second servo needs to be at neutral.
300 - 150 = 150
 

Bond

New Member
Yes I am interested in using the 08m2.
Are you saying if I use input 1 for the receiver and output 1 for the servo all I need to do is read the value from input 1 and apply it to output 1 with the maths
 

hippy

Ex-Staff (retired)
Are you saying if I use input 1 for the receiver and output 1 for the servo all I need to do is read the value from input 1 and apply it to output 1 with the maths
Almost.

The 08M2 will take the receiver's output into one of its inputs and will generate a servo signal on one of its outputs.

You need a separate input from the receiver and a separate output to the servo.
 

hippy

Ex-Staff (retired)
It is probably best to get your PICAXE reading the RC pulse and providing servo control without worrying about what direction the servo moves first, then look at reversing its direction if that is required.
 

Goeytex

Senior Member
You cannot use pulsin and servo commands in the same program without some serious servo glitching.

The following code gets around that. The receiver output connects to Pin C.4 and the new servo output connects to C.2. The servo will rotate in the opposite direction from the receivers output. You may have to adjust the numbers based upon the behavior of your particular servo.

Code:
'===================================
#Picaxe 08M2
#No_Data
Setfreq M32
Pause 100
'=====================================

do 
   
   pulsin C.4,1,w0    [COLOR="#008000"] 'wait for pulse from receiver[/COLOR]
   w0 = w0 max 1760 min 560  [COLOR="#008000"] '2.2ms  to .7 ms    [/COLOR] 
   w1 = 1760 - W0 + 560  [COLOR="#008000"]  'Do The Math[/COLOR]
   pulsout C.2, w1  [COLOR="#008000"] 'Output to Servo  [/COLOR]
     
Loop
 
Top