|
Post by dave on Nov 26, 2017 17:37:10 GMT
like this? Attachments:
|
|
|
Post by c3po on Nov 26, 2017 18:00:36 GMT
Like that code - no flipping semi colons - the bane of my life! code for picaxe, but easy to transfer to Arduino... #picaxe 20x2 b1=3 w3=0 w3=599 main: ;=== switch smoke ON/OFF === pulsin b.7,1,w2 if w2>300 then high c.0 else low c.0 endif ;========================== ;=== throttle input ======= ;=== convert to 799 max for fam === pulsin b.6,1,w3 if w3>295 then w4=w3-295 max 100 else w4=295-w3 max 100 endif if w4>14 then b1=255 endif if w4<15 then let w4=0:endif ; min cutoff w5=w4*8 max 799 if b1=255 then w5=w5 min 250 ; minimum fan speed pwmout C.5, 199, w5 ; fan output endif if b1>3 and b1<255 then pwmout C.5, 199,200 endif if b1<2 then pwmout C.5, 199, 0 endif dec b1 if b1<100 then ; fan run on time b1=1 endif ;========================= ; = smoke 1 on/off ====== if w4>15 then high c.3 else low c.3 endif ;======================== ;=== smoke 2 on/off ==== if w4>55 then high c.2 else low c.2 endif ;======================= ;== running lights ===== pulsin b.5,1,w6 if w6>300 then high b.0 high b.2 else low b.0 low b.2 endif ;===================== ;=== cabin lights ==== pulsin b.4,1,w7 if w7>300 then high b.1 high b.3 else low b.1 low b.3 endif ;=================== goto main
|
|
|
Post by c3po on Nov 28, 2017 21:48:33 GMT
Dave,
How did you design that circuit board - looks mega complex
|
|
|
Post by dave on Nov 29, 2017 8:15:56 GMT
|
|
|
Post by c3po on Nov 29, 2017 11:10:20 GMT
Dave - Thank you
Something else to learn!
I'll link this in the "Useful links" section
|
|
|
Post by dimtim on Nov 29, 2017 21:32:23 GMT
I've added the following to the code but only works if i unplug the chanel for the fan input. any ideas. if(rc3 > 1800) { digitalWrite(led, HIGH);} { if(rc3 < 1380) digitalWrite(led, LOW); }
int enable1 = 10; int rc_channel4 = 3; int rcswitch = A0; int led = 11; void setup() { pinMode(rc_channel4, INPUT); pinMode(enable1, OUTPUT); pinMode(rcswitch, INPUT); pinMode(led, OUTPUT);
}
void loop() { int pwm = 0; int rc4 = pulseIn(rc_channel4, HIGH, 25000); // throttle int rc3 = pulseIn(rcswitch, HIGH, 25000); // lights if(rc3 > 1800) { digitalWrite(led, HIGH);} { if(rc3 < 1380) digitalWrite(led, LOW); } if(rc4==0){ analogWrite(enable1, 80); } else if(rc4 > 1500){ pwm = map(rc4, 1485, 1970, 255, 100); analogWrite(enable1, pwm); } else if(rc4 < 1460){ pwm = map(rc4, 1480, 986, 255, 100); analogWrite(enable1, pwm); }else { analogWrite(enable1, 80); } }
Cheers
|
|
|
Post by dimtim on Nov 29, 2017 22:04:17 GMT
Does't matter finally got the Interput working correctly
|
|
|
Post by c3po on Nov 29, 2017 22:39:36 GMT
Hi Tim,
Pleased you got it working - not sure if this may also affect you or maybe this was the issue
if(rc3 > 1800) { digitalWrite(led, HIGH);} { if(rc3 < 1380) !! Missing bracket.... digitalWrite(led, LOW); }
or was this "ELSE"
if(rc3 > 1800) { digitalWrite(led, HIGH); } else { if(rc3 < 1380) digitalWrite(led, LOW); }
The one thing I find about Arduino programming is with such a small instruction set I still make zillions of syntax errors!
|
|
|
Post by dimtim on Nov 30, 2017 18:00:58 GMT
Thanks c3po, can't beleive it all cause of a missing }.
in some way i'm glad it failed as forced me to to get the interputs script work which i think will be better for future projects.
cheers tim
|
|
|
Post by c3po on Nov 30, 2017 20:08:39 GMT
Tim,
Interrupts by far the best and quickest way to go.
I have a shell that I just plonk the code into - chances are I can't even remember how the RC interrupt code works as I don't even look at it...
The other thing that is so annoying is that it's really easy to see typo's in someone else code but not your own - leading to hours of frustrating debugging....
C-3PO
|
|
|
Post by dimtim on Nov 30, 2017 21:17:43 GMT
yep, thought i had lost the working template ino file i had. lucky i fired up one of my usb drives and found it
|
|
|
Post by dimtim on Feb 16, 2018 18:24:03 GMT
been messing around with this project to work with my robbe sound unit.
instead of using two extra channels to switch on the leds and board. I wait to use the two extra output of the sound unit(believe they just go high/low). But still need the throttle input from the rx,
how would you alter the RC interupt scipt to read one chanel from the rx and then the other 2 from a high low signal or is it not possible. already tried removing the msec to high/low and putting in digitalRead)
Just thought this will come in handy for other idea where the interupts could be limit switches.
cheers
|
|
|
Post by c3po on Feb 16, 2018 20:29:45 GMT
Hi Tim
Not sure I follow your post.
Are you wanting to read 3 channels from Rx
One proportional throttle and 2 TX switch on or off?
Jonathan
|
|
|
Post by dimtim on Feb 16, 2018 22:12:15 GMT
Cheers c3po,
Really pleased with my self. sat down had a beer and cig and got it working.
basiclly it read the throttle signal like normal but the other two inputs are from the robbe sound unit(basicly a 8 ch decoder) so in theory this can be used on any device now.
|
|