View Full Version : Discussion 3 position rc electronic switch schematics?
oracle_9
Sep 28, 2009, 02:29 PM
I know there is the r/c switch circuit diagrams from uguelph which is a on/off electric switch. (like for relays, lights, etc.). This is basically either ON or OFF (2 position).
Is there a circuit somewhere thats 3 position? (ON, OFF, ON) to turn on two different things, and a neutral off for both of them.
For example: Move the stick forward it turns one relay to "ON", but when you pull the stick back it turns a different relay to "ON" and neutral stick position is "OFF" for both relays.
If anyone knows of a circuit diagram, I would greatly appreciate it.
Thanks.
Malc C
Sep 28, 2009, 03:06 PM
Not sure of one using discrete components, but you can do this with a PIC micro by setting thresholds for the pulse width, so for example <1.25ms make pin 1 high (relay one) >1.25 but <1.75ms make pin 1 and 2 low (both off) and >1.75 make pin 2 (relay two) high.
earlwb
Sep 28, 2009, 03:28 PM
I used to use the old fashioned method, The servo arm had a small piece of copper or brass attached to it along with a ground wire. As you moved the servo arm, it would contact various other pieces of metal and complete the circuit for something. Very similar to a rotary switch. One could also take a small rotary switch, remove the detents and hook it up directly to a servo as well.
You can program a small microprocessor to receive the pulse width signal from the receiver (1ms to 2ms, with 1.5ms being the center) and then program the output pins to go high or low based on the pulse width. The output pins can then drive a power transistor(s) to turn something on or off, without using relays. The simple Darlington Power transistors would work nice for this as they are fairly inexpensive, but one could go for the MOSFETS too. if you are driving something small that doesn't need more than 50 to 100 ma, a simple transistor would work.
oracle_9
Sep 28, 2009, 05:09 PM
Actually, currently, a servo is used to activate switches, as you described using metal contacts. Although, connecting it directly to a rotary switch is a neat idea too!
I am hoping there would be a circuit out there that doesnt need programming. I dont know much about PIC's, but they sound complicated and expensive to set up.
RoGuE_StreaK
Sep 29, 2009, 01:42 AM
I dont know much about PIC's, but they sound complicated and expensive to set up.Complicated kinda, expensive no. $20 will get you a programmer, then from then on you can do stuff that'd cost a whole heap more to do with electronics as the logic handlers. That said, I haven't figured out how to read servo signals yet, so I guess that puts a crimp on things. Controlling light patterns and the like is a piece of cake though.
AleG recently linked to this thread (http://www.rcgroups.com/forums/showthread.php?t=973183) in response to a similar query I had, it uses Atmel chips which are different again from PICs, but seems kinda close to what you want, you can switch on or off two different devices, but by waggling the stick, not from three different stick positions.
feegie park
Sep 29, 2009, 08:34 AM
Servo and microswitch is less reliable than the PIC micro solutions suggested but actually better than those type of circuits you get from guelph.
If you are willing to tolerate the occasional glitch that you get from those simple glue-logic circuits then hack a servo.
Acetronics
Sep 29, 2009, 09:15 AM
Hi, Oracle
A bit Oldie ... but working fine :
http://www.elektor.nl/artikelen-als-pdf/1997/juni/rc-biswitch.50009.lynkx
uses a couple of CD 4538 and a 4013 ...
Note the dutch article version is the only one still available ... but scheme international !!! :D
PCB available too.
Alain
AleG
Sep 29, 2009, 11:06 AM
AleG recently linked to this thread (http://www.rcgroups.com/forums/showthread.php?t=973183) in response to a similar query I had, it uses Atmel chips which are different again from PICs, but seems kinda close to what you want, you can switch on or off two different devices, but by waggling the stick, not from three different stick positions.
Indeed, the code could easily be adapted to switch on the outputs when the input signal goes, for example, above 1.8ms and bellow 1.2ms.
I haven't tried it, but I suppose it could be rewritten like this:
#define F_CPU 9600000UL // 9.6MHz
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/interrupt.h>
volatile unsigned int Tick; // Timer count variable
volatile unsigned char sPulse; // Incoming servo pulse measured length
volatile unsigned int sPulseIn; // Incoming servo pulse measurement
volatile unsigned char ServoCurrent; // Current position of the output servo
volatile unsigned char ServoTarget; // Target position of the output servo
unsigned char Right_1; // Stick on right position flag
unsigned char Left_1; // Stick on left position flag
unsigned int pRight; // Right sPulse threshold
unsigned int pLeft; // Left sPulse threshold
unsigned char window; // Window of opportunity to switch states
unsigned char restore_SREG; // SREG status temporary store
unsigned char ServoStep; // Step the servo in one direction
unsigned char ServoSubStep; // Controls speed of servo rotation
int main (void)
{
sei(); // Enable global interrupts
DDRB &= ~(1<<PB1); // PB1 as input
DDRB |= (1<<PB0) | (1<<PB2) | (1<<PB3) | (1<<PB4); // PB0 and PB2 as output
TCCR0A |= (1<<WGM01); // Configure timer 1 for CTC mode
TIMSK0 |= (1<<OCIE0A); // Enable CTC interrupt
OCR0A = 95; // Set CTC compare value
TCCR0B |= (1<<CS00); // No prescaler
GIMSK |= (1<<INT0); // Enable INT0 interrupt
MCUCR |= (1<<ISC00) | (1<<ISC01); // INT0 interrupt on rising edge
Tick = 0; // Initialize timer at 0
ServoCurrent = 100; // Initialize output servo at far left position
ServoTarget = 100; // Initialize output servo target at far left position
sPulse = 150; // Set initial state of pulse width
pRight = 175; // Long pulse threshold
pLeft = 125; // Short pulse threshold
window = 5; // Time window for stick motion
while(1)
{
sei(); // Enable interrupts
/*Monitor if stick is left or right*/
/*MODIFIED CODE*/
if(sPulse >= pRight) // True if stick right past threshold
{
PORTB ^= (1<<PB3); // Toggle Output A, pin 2
}
if(sPulse <= pLeft) // True if stick left past threshold
{
PORTB ^= (1<<PB4); // Toggle Output B, pin 3
}
/*MODIFIED CODE*/
}
}
ISR(TIM0_COMPA_vect) // 100KHz timer interrupt
{
restore_SREG = SREG; // Save register status
cli(); // Disable interrupts
/* Servo Out pulse generation */
if(Tick <= ServoCurrent) // While the Tick count is less than the maximum pulse length
{
PORTB |= (1<<PB0); // Keep pin 5 high
}
else
{
PORTB &= ~(1<<PB0); // Keep pin 5 low for the reminder of the servo frame
}
if(Tick >= 2000) // One servo frame (20ms) completed
{
Tick = 0; // Reset counter
}
Tick += 1; // Increment counter
sPulseIn += 1; // Increment the incoming servo pulse value
SREG = restore_SREG; // Restore status register
sei(); // Enable interrupts
}
/* Servo In pulse measurement and servo Out position setting */
ISR(INT0_vect) // Servo input interrupt
{
restore_SREG = SREG; // Save register status
cli(); // Disable interrupts
if(MCUCR & (1<<ISC00)) // If incoming servo pulse begins (rising edge)
{
sPulseIn = 0; // Start pulse count
/* Servo Out rotation speed*/
ServoSubStep += 1; // Increment servo position substep
if(ServoSubStep >= 3) // ServoSubStep >= *less faster, more slower*
{
ServoStep = 1;
ServoSubStep = 0;
}
/*Set interrupt sense to falling edge*/
MCUCR |= (1<<ISC01);
MCUCR &= ~(1<<ISC00);
}
else // If incoming servo pulse ends (falling edge)
{
if(ServoStep) // If it's time to step Servo Out in one direction
{
if(ServoCurrent < ServoTarget)
{
ServoCurrent += 1; // Step Servo Out right
}
if(ServoCurrent > ServoTarget)
{
ServoCurrent -= 1; // Step Servo Out left
}
ServoStep = 0; // Reset and wait for next servo step command
}
sPulse = sPulseIn; // Measure Servo In pulse length
/*Set interrupt sense to rising edge*/
MCUCR |= (1<<ISC00) | (1<<ISC01);
}
SREG = restore_SREG;
sei();
}
It should be tested though, since I just deleted almost all the main program routine and left some subroutines orphaned inside the interrupts.
orraman
Sep 29, 2009, 12:09 PM
You could download the free Picaxe Programming Editor, select 08M, copy and paste this simplistic program, click Simulate, change Generic to 100, 150, 200, 100 and observe the action.
Programming is done down 3 serial wires at one click.
If I can help?
Dave
www.picaxe.co.uk
In Canada
PICAXE 08M $3.50
PICAXE-08 Proto Board Kit @ $4.99 measures 2.1 x1.2 inches with room for transistors or FETs, there is also a Surface Mount 08m available installed on a board.
http://www.hvwtech.com/search/search_main.asp?zoom_query=picaxe
http://www.robotshop.ca/ProductSearch.aspx?qs=picaxe
code
'Stick centre pulse is 150. (') = comment :defines place Label
START:
pulsin 3,1,b2 '......................RX on pin 4 into variable b2
if b2 < 130 then goto LEFT
if b2 > 170 then goto RIGHT
low 1 '................................cancel earlier action
low 2 '................................ "
goto START '.......................await next RX pulse
LEFT:
high 1 '...............................+5V on pin 6 to transistor
goto START
RIGHT:
high 2 '...............................+5V on pin 5 "
goto START
RoGuE_StreaK
Sep 29, 2009, 06:18 PM
pulsin 3,1,b2 '......................RX on pin 4 into variable b2You're kidding me? That's it? Damn, gotta get me something like this for general PICs, seems waaaaaay too simple to be true, but if it is, hell yeah! No more messing for hours with interrupts...
oracle_9
Sep 29, 2009, 09:22 PM
Wow, this is overwhelming. I have no clue about the programming though. But, I can solder good though!
Picaxe seems to be at a good price though.
orraman
Sep 30, 2009, 02:43 AM
.
RoGuE StreaK,
There is a great following for Picaxe in AU and NZ with leading contributors in the Picaxe Forum. The forum is without doubt one of the most welcoming forums on the web for beginners or those needing help with advanced or interesting projects. Pic Datasheets and a profound understanding of the device are not needed.
Oracle 9,
Being dyslexic, for me the amount of Picaxe information is overwhelming so I work with a reduced sub-set of the available commands.
Count the commands in the program above and add Pause, Servo, For, Readadc and that covers most of what is needed for models.
I tend to search for a Picaxe program that does most of what I want and use the good bits. Servoslowdown and mixers by Kevin Goom helping me to make programs for cameras, low voltage cut-offs and switches.
If I can help?
Dave
Acetronics
Sep 30, 2009, 03:19 AM
Hi, Oracle
I do Agree with Orraman : Picaxe is as simple as that to use; of course it needs some BASIC programming skills, but really ... basic skills !
never used some QuickBasic , HP Basic, Casio Basic or GW Basic ??? ... would be surprising ...
Of course, this program snippet is the minimum size one ... but it's really easy to turn it to near an " idiotproof " version ( no pulse or glitch preventing ... etc, etc ).
Alain
Tomapowa
Sep 30, 2009, 11:12 AM
.
RoGuE StreaK,
There is a great following for Picaxe in AU and NZ with leading contributors in the Picaxe Forum. The forum is without doubt one of the most welcoming forums on the web for beginners or those needing help with advanced or interesting projects.
True.... but never ever even hint any form of advertisement there (picaxe forums)... I got banned years ago when trying to show something R/C related I built and some thought I was advertising it there....! :eek: :cool: Just another unfortunate case of newsgroup moderators having way too much power (or so they think). :)
Acetronics
Sep 30, 2009, 11:54 AM
Hi, Tomapowa
and some thought I was advertising it there....!
:D :D :D :D :D :D :D :D :D :D
Unbearable injustice ....
So, you don't ?
Alain
Tomapowa
Sep 30, 2009, 11:59 AM
So, you don't ?
So I don't what ??? :confused:
Acetronics
Sep 30, 2009, 12:06 PM
ADVERTISE !!!
What Else ??? ... Nespresso ??? :rolleyes:
Alain
Tomapowa
Sep 30, 2009, 12:20 PM
ADVERTISE !!!
What Else ??? ... Nespresso ??? :rolleyes:
Alain
OH! :) Sry...you sometimes need to be more specific... (maybe it's just the lawyer in me). I have no need to advertise as my r/c gadgets historically sell themselves. Plus I can't keep up with the production demand as it is... some do have real day-time jobs you know! :cool:. Gadgets I can not produce/sell myself are eventually sold (product design rights) to others manufacturers (57 ideas/patents to date to be exact).
orraman
Sep 30, 2009, 12:31 PM
Nah and he wasn't and he didn't but! :cool:
I felt most aggrieved at the time particularly as others had offered the same kind of helpful information and had not been banned.
At that time Tom's site was the best advertisement for Picaxe in the USA and that action was unfair and unwarranted.
Today I searched in Google for "Goom Picaxe" and found that his Servoslowdown program was still on Tom's site and thought that that reflects well on the program and on Tom.
Among other items was a fully documented conversion of that program into the C language.
Alain,
It was good that someone of your programming capability was willing to acknowledge the usefulness of the Picaxe, it sure made a change from my preaching.
Dave
PS being dyslexic I took so long with the above I was 5 posts late as usual.
Tomapowa
Sep 30, 2009, 01:13 PM
Hi Dave,
Thanks for the kind comments and accurate views. I still use the Picaxe (believe it or not... after the crap I went through) for quick prototypes and eventually convert to PicBasic for burning my own bare PICs. One project I still am having issues with when converting Picaxe to PicBasic is my "Mini-Flash" LED controller project (not intended to be any form of advertisement... thought I'd stick that out there now! :cool: ). One area where the Picaxe excels I think is in the imbedded interrupt routines they provide... much easier in Picaxe as it is in PicBasic. I still have not been able to convert this code into PicBasic code so I still have to use the Picaxe for this project. :cool:
I also noticed that Peter Anderson (http://phanderson.com/picaxe/) is now an official Picaxe distributor here in the US... not only is he a real nice guy, but he also sells the Picaxes for the lowest cost I could find... (bigger the quantity, the better the price). Plus, Peter provides a buch of workable code to mess with and edit to your liking...
If any one has not yet tried the Picaxe, you are really missing out. As Dave already mentioned, most required functions for R/C gadgets (pulsin, pulsout, servo, ADCin, etc...commands are there for you to use.... and real simple to learn, program and tinker with. As much as I hate saying this... Try it, you'll like it!
Acetronics
Sep 30, 2009, 02:10 PM
I have also developed (& sold) numerous R/C functional libraries for MEL's PicBasic library so be sure to check them out too when they start selling them (early 2010 supposedly).
Wowwwwww,
Melabs Providing dedicated libraries ...
THAT's the news of the century ... ;)
be sure I will be in the beta testers team ...
Alain
vBulletin® Copyright ©2000-2010, Jelsoft Enterprises Ltd.