RGB LED "TICK"
Moderator: Benj
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
RGB LED "TICK"
Hi,
I have a simple circuit that works fine in simulation however when I look at the help file it says that I must use the Tick command in a loop otherwise the LED modulation will not work properley, could anybody spread any light on this please...
thanks in advance
Acestu
EDIT: I have just noticed that the display numbers are not working correctly either
I have a simple circuit that works fine in simulation however when I look at the help file it says that I must use the Tick command in a loop otherwise the LED modulation will not work properley, could anybody spread any light on this please...
thanks in advance
Acestu
EDIT: I have just noticed that the display numbers are not working correctly either
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: RGB LED "TICK"
Hi Stuart
You need to put the tick command in on hardware.
Think this file works, not got time to test it at the moment.
You need to put the tick command in on hardware.
Think this file works, not got time to test it at the moment.
1 in 10 people understand binary, the other one doesn't !
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi John,
Thanks for the info, I will have another look at my chart because I see that you have the command in there 3 times..
cheers
Acestu
Thanks for the info, I will have another look at my chart because I see that you have the command in there 3 times..
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi
I have changed the chart to include the ticks, I haven't got my rgb leds yet so I cant try in hardware but when I run the simulation, I change the sliders around and the values update on the lcd but when I bring them back to zero, zero is not what it says on the lcd, have I got the code wrong somewhere ?
thanks
Acestu
I have changed the chart to include the ticks, I haven't got my rgb leds yet so I cant try in hardware but when I run the simulation, I change the sliders around and the values update on the lcd but when I bring them back to zero, zero is not what it says on the lcd, have I got the code wrong somewhere ?
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: RGB LED "TICK"
Hi Stuart
You only need the tick after the RGB led icon
If you dont have a RGB led, you can always use 3 standard leds, resistors in the anodes to the PIC and common the cathodes together to ground.
That way at least you can test the flowchart.
Think the reason the LCD does not show 0 is its not clearing the last reading, when you come from 3 digits to 2 if you move it quickly it might skip 100 and the 3 digit will not change form 99 to 0
You only need the tick after the RGB led icon
If you dont have a RGB led, you can always use 3 standard leds, resistors in the anodes to the PIC and common the cathodes together to ground.
That way at least you can test the flowchart.
Think the reason the LCD does not show 0 is its not clearing the last reading, when you come from 3 digits to 2 if you move it quickly it might skip 100 and the 3 digit will not change form 99 to 0
1 in 10 people understand binary, the other one doesn't !
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi John
When you say "Think the reason the LCD does not show 0 is its not clearing the last reading, when you come from 3 digits to 2 if you move it quickly it might skip 100 and the 3 digit will not change form 99 to 0"
Is this in the simulation or will it do the same in hardware ?
And I have plenty of leds so I think i will try that John
thanks
Stuart
When you say "Think the reason the LCD does not show 0 is its not clearing the last reading, when you come from 3 digits to 2 if you move it quickly it might skip 100 and the 3 digit will not change form 99 to 0"
Is this in the simulation or will it do the same in hardware ?
And I have plenty of leds so I think i will try that John
thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi John
Sorry about the time lagg there, your MK3 works fine now, I am just having a go at hardware but I can't find any sliders, I can use some rotary pots though can't I ?
thanks
Stuart
Sorry about the time lagg there, your MK3 works fine now, I am just having a go at hardware but I can't find any sliders, I can use some rotary pots though can't I ?
thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: RGB LED "TICK"
Yes any type of pot should work.
Proberbly best if you have all 3 the same value.
Proberbly best if you have all 3 the same value.
1 in 10 people understand binary, the other one doesn't !
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi
Ok I have changed the device to a Pic16F877A because I have a spare one and I have 3 x linear 10k pots so I am going to have a go at building it with an ICSP header, I am enclosing a pic of the circuit if anyone else wants to have a go...
cheers
Stuart
Ok I have changed the device to a Pic16F877A because I have a spare one and I have 3 x linear 10k pots so I am going to have a go at building it with an ICSP header, I am enclosing a pic of the circuit if anyone else wants to have a go...
cheers
Stuart
Last edited by acestu on Sat May 11, 2013 1:58 am, edited 1 time in total.
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi,
I have put the circuit together but I have some strange results, the leds are flashing on and off, do you think it might be because I am using separate leds and I have the Tick component in the code ?, have a look at the video here:
http://www.youtube.com/watch?v=yn2KfKyz ... tion=share
thanks
Stuart
I have put the circuit together but I have some strange results, the leds are flashing on and off, do you think it might be because I am using separate leds and I have the Tick component in the code ?, have a look at the video here:
http://www.youtube.com/watch?v=yn2KfKyz ... tion=share
thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi,
I am not sure if the circuit is right either, I have had a look at a few other circuits and they have resisters and caps on the pot inputs, if anyone can help I would appreciate it . . .
Cheers
Stuart
I am not sure if the circuit is right either, I have had a look at a few other circuits and they have resisters and caps on the pot inputs, if anyone can help I would appreciate it . . .
Cheers
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: RGB LED "TICK"
Hi Stuart
I would maybe try just the pots and leds to start with, using the programmer and a protoboard (Keep it as simple as possible)
Do not connect the ISP header and maybe even leave of the lcd.
I would maybe try just the pots and leds to start with, using the programmer and a protoboard (Keep it as simple as possible)
Do not connect the ISP header and maybe even leave of the lcd.
1 in 10 people understand binary, the other one doesn't !
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi John,
Yes that is what I have done in the video, the pots are showing changes in the lcd but the leds are behaving weirdly ie flashing on and off when I am not even touching the pots..
thanksStuart
Yes that is what I have done in the video, the pots are showing changes in the lcd but the leds are behaving weirdly ie flashing on and off when I am not even touching the pots..
thanksStuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi,
OMG I bought some RGB leds from Ebay the other day so I could look at this properly, they have just come and they are common Anode, I never even thought about that, oh well I will just have to order some more and wait again...
cheers
Acestu
OMG I bought some RGB leds from Ebay the other day so I could look at this properly, they have just come and they are common Anode, I never even thought about that, oh well I will just have to order some more and wait again...
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: RGB LED "TICK"
Hi Stuart
I'm at work so not able to check, but I think you can select common anode
or cathode in properties.
I'm at work so not able to check, but I think you can select common anode
or cathode in properties.
1 in 10 people understand binary, the other one doesn't !
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi John,
In External properties there is Active High & Active Low so if I change this and reprogram the chip do you think that will work ?
thanks
Acestu
EDIT: I have just changed the LED to active low and reprogrammed but it does not work the chip output polarity is still the same, just an opposite effect on the pots.
In External properties there is Active High & Active Low so if I change this and reprogram the chip do you think that will work ?
thanks
Acestu
EDIT: I have just changed the LED to active low and reprogrammed but it does not work the chip output polarity is still the same, just an opposite effect on the pots.
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: RGB LED "TICK"
Hello,
For a common anode LED you need to connect the anode to 5V and then connect each of the RGB cathodes to a pin on the microcontroller.
It sounds like the common anode/cathode functionality is working correctly if the pots now run the opposite way.
Basically when a channel is set to 255 a common anode will be off 100% of the time and a common cathode will be on 100% of the time.
Might be a bit late but Rapid sell some linear actuator pots.
http://www.rapidonline.com/Electronic-C ... ters-65234
For a common anode LED you need to connect the anode to 5V and then connect each of the RGB cathodes to a pin on the microcontroller.
It sounds like the common anode/cathode functionality is working correctly if the pots now run the opposite way.
Basically when a channel is set to 255 a common anode will be off 100% of the time and a common cathode will be on 100% of the time.
Might be a bit late but Rapid sell some linear actuator pots.
http://www.rapidonline.com/Electronic-C ... ters-65234
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi Benj,
Thanks for that, yes my fault I forgot to change common from pos to neg, but even now I have done that the circuit acts really strangely ie flashes on and off as the separate LEDS did., am I right in thinking that each pin out to the LED is a variable smooth voltage controlled by the pot ?. I will post a video in a minute or 2.
Thanks
Acestu
Thanks for that, yes my fault I forgot to change common from pos to neg, but even now I have done that the circuit acts really strangely ie flashes on and off as the separate LEDS did., am I right in thinking that each pin out to the LED is a variable smooth voltage controlled by the pot ?. I will post a video in a minute or 2.
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi,
This is a video of the circuit, for some reason without touching anything the LED flashes on and off in different colours, any ideas ?
https://www.youtube.com/watch?v=IpT9O0WGTmQ
thanks
Acestu
This is a video of the circuit, for some reason without touching anything the LED flashes on and off in different colours, any ideas ?
https://www.youtube.com/watch?v=IpT9O0WGTmQ
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: RGB LED "TICK"
Hello,
Aha yes I see it is off on one a bit isn't it. Can you attach your current program and I will have a look for you.
Aha yes I see it is off on one a bit isn't it. Can you attach your current program and I will have a look for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi Benj,
Thanks here is my current chart....
Thanks
Acestu
Thanks here is my current chart....
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: RGB LED "TICK"
Hello,
Ok try this, I have moved the tick command into a timer interrupt to allow it to run at high speed in the background and leave your main application for reading ADC channels and writing to the LCD. Hopefully the actual output colour should now be stable.
Let me know how you get on.
Ok try this, I have moved the tick command into a timer interrupt to allow it to run at high speed in the background and leave your main application for reading ADC channels and writing to the LCD. Hopefully the actual output colour should now be stable.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RGB LED "TICK"
Hi Benj,
That seems to of done the trick:
https://www.youtube.com/watch?v=YPSI_fDRJPo
"I have moved the tick command into a timer interrupt to allow it to run at high speed in the background"
I am just trying to understand what you have changed, does this mean that the program is halted when it is time to implement the Tick command so that it is priority ?
EDIT: I see that you have put the Tick command in its own Macro, Does TMR0 interupt on TMR0 mean that when the program gets down to that line it starts the timer and interrupts straight away and calls the Tick Macro ?
And could you tell me what method the RGB module is using to dim the LED's
Thanks
Acestu
That seems to of done the trick:
https://www.youtube.com/watch?v=YPSI_fDRJPo
"I have moved the tick command into a timer interrupt to allow it to run at high speed in the background"
I am just trying to understand what you have changed, does this mean that the program is halted when it is time to implement the Tick command so that it is priority ?
EDIT: I see that you have put the Tick command in its own Macro, Does TMR0 interupt on TMR0 mean that when the program gets down to that line it starts the timer and interrupts straight away and calls the Tick Macro ?
And could you tell me what method the RGB module is using to dim the LED's
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: RGB LED "TICK"
Hello,
Thanks for the updated video looks very nice and stable now
The timer interrupt is enabled just before you enter the infinite main loop so we can rattle around the loop at any speed we wish but the timer tick will remain constant.
The timer interrupt is used to call the RGB Tick macro which basically compares an internal counter with the current specified values of R, G and B. If the counter is less then the R, G, B value then the relevant R, G, B pin is switched on. If the counter is more then the R, G, B value then the output is switched off. Essentially we have a 3-channel software PWM.
The counter looks after itself and so will automatically wrap around and begin again. As long as the tick macro is called at least (64 ticks * 30Hz) timer per second then you shouldn't see any flickering on the output. You can change how many ticks per cycle if you like by editing a definition but 64 seems to work quite well and allows a large colour selection (18-bit colour). The max possible colour depth with 8-bit variables is 24-bit colour.
Thanks for the updated video looks very nice and stable now
The timer interrupt is enabled just before you enter the infinite main loop so we can rattle around the loop at any speed we wish but the timer tick will remain constant.
The timer interrupt is used to call the RGB Tick macro which basically compares an internal counter with the current specified values of R, G and B. If the counter is less then the R, G, B value then the relevant R, G, B pin is switched on. If the counter is more then the R, G, B value then the output is switched off. Essentially we have a 3-channel software PWM.
The counter looks after itself and so will automatically wrap around and begin again. As long as the tick macro is called at least (64 ticks * 30Hz) timer per second then you shouldn't see any flickering on the output. You can change how many ticks per cycle if you like by editing a definition but 64 seems to work quite well and allows a large colour selection (18-bit colour). The max possible colour depth with 8-bit variables is 24-bit colour.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel