irin vs servo

castlerocks

New Member
Dear all,

I seem to have a problem with running an infrared controlled device (20x2-based) that, among other things, has to control two servos for a crossing gate. I have previously done this with a separate 08M2 running each gate, but for various reasons this is not available for this project. With irin command in the code, the servos are jittery which causes a disaster in a delicate installation like mine. With irin out of the code, servos run reasonably fine after some 1500uF decoupling was added here and there :).

I believe, the problem is irin and servo are using the same timer or some timer related setup registers. I have shifted timers around before, but for hpwm and pwm commands. What would be a way to do this?

Thank you all for your time,

Edmunds
 

AllyCat

Senior Member
Hi,

The IRIN command automatically switches the clock frequency to 4 MHz whilst it executes itself (to give correct timings) which will upset the servo timer. Normally X2s can be used with servos only at 8 MHz or 32 MHz, but it appears that you could set the default clock frequency to 4 MHz and then set the [preload] parameter in the SERVO command to give the correct 20 ms servo period.

Cheers, Alan.
 

erco

Senior Member
@edmunds (is Castlerocks your new soul?)... I have not used a 20X2, only M2 devices, which handle mixing SERVO and IRIN commands perfectly, as I posted about here. Must be some X2 idiosyncracy.

If you needed all those filter caps just to get the servos running, I think I smell a power supply problem. Servos need lots of current, up to an amp each in spikes. You are using SERVOPOS to update, right?

Occasionally I see others here recommending to use brute force and PULSOUTs in lieu of SERVO when glitches are encountered, which I think is an abomination. SERVO is one of the best things that Picaxe brings to the party IMO. :)
 
Last edited:

castlerocks

New Member
Hi,

The IRIN command automatically switches the clock frequency to 4 MHz whilst it executes itself (to give correct timings) which will upset the servo timer. Normally X2s can be used with servos only at 8 MHz or 32 MHz, but it appears that you could set the default clock frequency to 4 MHz and then set the [preload] parameter in the SERVO command to give the correct 20 ms servo period.

Cheers, Alan.
Dear Alan,

Thank you for the explanation, this must be it. I could not get the preload thingy to work although it should, I think and do not have much time to experiment this time around :).

/Edmunds
 

AllyCat

Senior Member
Hi,

I don't normally use X2s or Servos, but I would expect the X2 code to require a SETFREQ M4 and the preload field in the SERVO command to be written as [45536] which equals -20000 (us). Or if you're using the 20X2 , could you just swap in a 20M2, provided you're not using any of the more advanced X2-only commands (some of which might be emulated in the M2 code) ?

Cheers, Alan..
 

edmunds

Senior Member
Hey, my identity is back!

AllyCat - I used exactly what you are proposing, but for some reason it did not work. I did not have time for longish investigation, so it might be I still did something wrong, but the preload I calculated (the same number as yours) threw servos in all directions except where they should be. As the gate was already built, I could not experiment too much because of the risk of breaking something.

I solved this easily with pulsout replicating the servo command this time around. The customer is happy and that is what had to be achieved.

On a side, RevEd not selling the TV style remote anymore was a problem I did not expect. I ordered some remotes from ebay now and will see if any of them work well with sony IR protocol. Obviously, a full scale TV/VCR remote is not a good option for most micro-controller projects, so a good option like the good old blueish thing from RevEd is not so trivial to find.


Best regards to all,

Edmunds
 

hippy

Senior Member
Most keyfob remote controls will allow Sony IR codes to be selected, will often be the default.

It is possible to use a PICAXE-08M2, an IR LED, a couple of buttons and diodes to build your own.
 

erco

Senior Member
On a side, RevEd not selling the TV style remote anymore was a problem I did not expect. I ordered some remotes from ebay now and will see if any of them work well with sony IR protocol. Obviously, a full scale TV/VCR remote is not a good option for most micro-controller projects, so a good option like the good old blueish thing from RevEd is not so trivial to find.
Best. Remote. Ever. Almost all keys usable. Set code 049 for Sony SIRC. See my post & keymap at http://forums.parallax.com/discussion/comment/1331781/#Comment_1331781


Edit: attaching keymap here for those not wanting to be directed "off-campus" (outside of this forum).
 

Attachments

Last edited:

erco

Senior Member
Nice add Jim, thanks. I keep forgetting that 99% of Picaxe users are in the UK. IMO a crying shame that so few US hobbyists are even aware of Picaxe. I've beat the drum over here to no avail, but I'll keep spreading the gospel as time & energy allow.

Back to this fine remote: when in doubt, search on eBay for "TV-139F". Cheers!
 
Top