Hi all, firstly can I congratulate the authors of GCBasic for creating such a fantastic bit of kit. Within minutes I could generate code to buzz, flash, switch, time and all the other things that normally takes me weeks to do in that mystical code in MPlab.
This evening I have trawled over this forum like fisherman in tight kek’s trying to find a few snippets, stimulus or some scratch code which will allow me control a lighting sequence on a 12F508 with an RC PWM signal, 1500uS is Off >1650uS s is On
Several posts have come near to what I’m looking for but nothing seems to hit the button for me.
Any help would be really appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh has done a great job developing the GCBasic compiler, my favorite for sure.
Here is some polling code that should work with the 12F508, not tested but compiles. You can fool around with the Do_Loop and conditional test as you please.
#chip 12F508, 4
#config INTRC_OSC, MCLRE_OFF, CP_OFF, WDT_OFF
#define RX_Input GPIO.0
#define LED GPIO.1
dir GPIO b'001001' 'make GPIO.0 a digital input
count = 0
Main:
'This Do-Loop should be about 16 instrucions, or 16 us
'1 instr BTFSS, 12 instr wait 12 us (or use 12 nop's), 1 instr incf, 2 instr goto
Do While Rx_Input On
wait 12 us
Count += 1
Loop
If Count > 100 Then '1600 us
Set LED On
Else
Set LED Off
End If
count = 0
goto Main
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Kent, thank you kindly for your informative and quick reply. I don't honestly know how I missed this post, as I said previously that I had been all over the forum like a bad rash.
I am having a few of compilation errors which I having problems with. In the Compiler Output Dialogue Box it says;
Error in Main at 4: Syntax Error
Error in Main at 12: Syntax Error
Error in Main at 14: End If without If
Frankly I'm absolutely puzzled as to what is wrong, I have spent over two hours going over your code and I cannot find what it is that is preventing it from compiling, especially the last error at 14 as there is clearly an If statement above it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just a quick reply, and a huge thank you to Kent and Hugh for the code snippet. It works really well. Once I ironed out my syntax errors etc, In the target application I had to retard the count value to 85 which meant the device switched on at 1700uS instead of 2100uS with the count value at 100.
Now for the next challenge I need to get the result from the valid pulse detect out of the loop without it pulsing on and off.
Once again, any suggestions, hints, tips other than abuse would be gratefully accepted.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Heh, I guess I can't count :) or try the nop's for the delay. Some variation is expected because of the intosc.
Describe the receiver setup, are you decoding the whole raw RC pulse train, or individual channel ports, and how many?
If it is a multi-channel decode, than two or three things need to happen.
1. Use a Do-While loop to wait for channel 1's rising edge (only needed if decoding whole pulse train)
2. Use a counter to keep track of which channel is being decoded
3. Stuff the counter value into a channel variable to be used later
counter = 0
channel = 1
Main:
'Revised code here
'Put decoded pulse value into a variable for later use
If channel = 1 Then channel1 = counter
If channel = 2 Then channel2 = counter
If channel = 3 Then channel3 = counter
counter = 0
channel += 1 'increment channel
'check if 3rd channel decoded start again
If channel = 4 Then channel = 1
goto Main
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi again Kent, I'm back at the Honey-Pot again. There must be a simple way to do this, and as usual I'm looking at the hard way.
What I want to do is to make the output latching as in a flip-flop where the output stays high through low then triggers off on the next rising edge. I have been fiddling around with flags and the wait instruction but I think I am suffering fron information overload to where I cannot see the wood for trees.
Once again any help would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well I starting to lose track myself, of just where this is going. Good luck.
Here is a stab at it:
count = 0
Latch = 0
Main:
'This Do-Loop should be about 16 instrucions, or 16 us
'1 instr BTFSS, 12 instr wait 12 us (or use 12 nop's), 1 instr incf, 2 instr goto
'Do While Rx_Input On
' wait 12 us
' Count += 1
'Loop
'If Count > 100 Then LED = !Latch
If RX_Input On Then
Latch = !Latch
If Latch.0 = 1 Then Set LED ON
If Latch.0 = 0 Then Set LED OFF
End if
'count = 0
goto Main
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, firstly can I congratulate the authors of GCBasic for creating such a fantastic bit of kit. Within minutes I could generate code to buzz, flash, switch, time and all the other things that normally takes me weeks to do in that mystical code in MPlab.
This evening I have trawled over this forum like fisherman in tight kek’s trying to find a few snippets, stimulus or some scratch code which will allow me control a lighting sequence on a 12F508 with an RC PWM signal, 1500uS is Off >1650uS s is On
Several posts have come near to what I’m looking for but nothing seems to hit the button for me.
Any help would be really appreciated.
Hugh has done a great job developing the GCBasic compiler, my favorite for sure.
Here is some polling code that should work with the 12F508, not tested but compiles. You can fool around with the Do_Loop and conditional test as you please.
Kent
Hi Kent, thank you kindly for your informative and quick reply. I don't honestly know how I missed this post, as I said previously that I had been all over the forum like a bad rash.
I am having a few of compilation errors which I having problems with. In the Compiler Output Dialogue Box it says;
Error in Main at 4: Syntax Error
Error in Main at 12: Syntax Error
Error in Main at 14: End If without If
Frankly I'm absolutely puzzled as to what is wrong, I have spent over two hours going over your code and I cannot find what it is that is preventing it from compiling, especially the last error at 14 as there is clearly an If statement above it.
Found the errors in 12 and 14 ……. (Thick as Rhino Dung or What!)
Just a quick reply, and a huge thank you to Kent and Hugh for the code snippet. It works really well. Once I ironed out my syntax errors etc, In the target application I had to retard the count value to 85 which meant the device switched on at 1700uS instead of 2100uS with the count value at 100.
Now for the next challenge I need to get the result from the valid pulse detect out of the loop without it pulsing on and off.
Once again, any suggestions, hints, tips other than abuse would be gratefully accepted.
Heh, I guess I can't count :) or try the nop's for the delay. Some variation is expected because of the intosc.
Describe the receiver setup, are you decoding the whole raw RC pulse train, or individual channel ports, and how many?
If it is a multi-channel decode, than two or three things need to happen.
1. Use a Do-While loop to wait for channel 1's rising edge (only needed if decoding whole pulse train)
2. Use a counter to keep track of which channel is being decoded
3. Stuff the counter value into a channel variable to be used later
Kent
Oh… Mmm that looks interesting….
Need to have a poke around with that, see what it does…
Hi again Kent, I'm back at the Honey-Pot again. There must be a simple way to do this, and as usual I'm looking at the hard way.
What I want to do is to make the output latching as in a flip-flop where the output stays high through low then triggers off on the next rising edge. I have been fiddling around with flags and the wait instruction but I think I am suffering fron information overload to where I cannot see the wood for trees.
Once again any help would be appreciated.
Well I starting to lose track myself, of just where this is going. Good luck.
Here is a stab at it:
Kent