RGB led driver coding

Steve2381

Senior Member
Hi all.

Brief question really. I need to run an RGB strip (via TIP122's) for a project, but I need it up and running asap.
Going to use a 14m2 - 3 PWM outputs, but wondered if anyone has any links to coding already written to drive them? Kind of Christmas style chasing, fading, flashing etc.
I would normally happily write some code up, but I just don't have the time for this short notice project I have got roped into.

They have archives of Arduino sketches you can use, just wondered if there were any Picaxe libraries around?

Thanks
 

hippy

Technical Support
Staff member
Not sure what help there may be on the forum; I recall there are some Knight Rider 'KITT' car projects described, and some projects for full colour control of a single RGB LED using 3 channels of PWM.

It's not clear how your TIP122's ( Darlington transistors ) are to be used with an RGB strip. A little more detail there, particularly on the RGB strip, may lead to some suggestions.
 

Bill.b

Senior Member
This code will fade the three Colors on a 5m strip of 5050 RGB LEDs

Code:
'loop RGB LED Control
'May 2012
'Picaxe 14M2
#picaxe 14m2
#No_Data

symbol counter 		= W2
symbol Green	= W3
symbol Blue 	= W4
symbol loopcount	= b0

symbol Redout	= b.2
symbol Blueout	= c.0
symbol Greenout	= b.4

dirsb=%00011111
dirsc=%00000111
pwmout Redout,100,0
	pwmout Blueout,100,255
	pwmout Greenout,100,0
main:

gosub fade
'
goto main


fade:	

	for counter = 0 to 255
		  pwmduty Redout,counter
		  w5 = 255-counter
		  
		  pause 10
	 next counter
	 pause 400
	 for counter = 0 to 255
		  
		  w5 = 255-counter
		  pwmduty Blueout,w5
		  pause 10
	 next counter
	 pause 400
	 for counter = 0 to 255  
		  pwmduty Greenout,counter
		  
		  w5 = 255-counter
		  pwmduty Redout,w5
		  pause 10
	 next counter
	 Pause 400
	 pwmduty Redout,0
	 pause 200
	 for counter = 0 to 255
		  pwmduty Blueout,counter
		   w5 = 255-counter
		  pwmduty Greenout,w5
		  pause 10
	 next counter
	 pause 400
	 
	for counter = 0 to 255
	 w5 = 255-counter
		  pwmduty Blueout,w5
		  pwmduty Redout,counter
		  pwmduty greenout,counter
		   
		  pause 10
	 next counter

	 	 pause 400
	 		for counter = 0 to 255
	 w5 = 255-counter
		  pwmduty Blueout,counter
		  pwmduty Redout,w5
		  pwmduty greenout,w5
		   
		  pause 10
	 next counter
	
	 pause 400
'	pause 50
'		
'
'pwmout Redout,off
	'pwmout Blueout,off
	'pwmout Greenout,off
	return
RGBLEDControl.jpg

Bill
 

Steve2381

Senior Member
Well basically its 12v common to the strip, and the 3x colours are switched 0v. I usually drive a TIP122 with a 10k resistor from a PWM output. Seems to work.

Thanks for that code Bill, I might be able to adapt that code. Its a local fete and it needs to be up and running tonight!
 

Steve2381

Senior Member
Well I had to abandon using a Picaxe anyway:(

Usual Axe027 programming issues. Every other time I use the programmer I get a comms error and it refuses to talk to the Picaxe. Then I spend an hour messing around uninstalling drivers etc.
Don't know why it cannot remember the settings and just work. Its so frustrating..

I have uninstalled all the drivers, but I cannot get it to stop thinking that there is an (unavailable) Axe027 on ports 4 and 7. It thinks something is using the USB port, when there is nothing there.
I am using programmer 5.5.5, as I really don't like the later versions. That should not really be the issue.
How do you get the programmer actually clear itself and monitor the ports correctly?

Thank God for Arduino mini's
 
Last edited:

hippy

Technical Support
Staff member
How do you get the programmer actually clear itself and monitor the ports correctly?
The PICAXE software is very reliable, both the older PE5 and newer PE6.

Both use the information Windows supplies on the availability of serial ports and their types and both keep track of which ports were previously selected. Having unavailable AXE027 cables suggests there have been multiple AXE027 installations which Windows has allocated different COM port numbers to.

That can cause usability issues if the cable is moved between USB ports or Windows allocates a different COM port to previously. The COM port the AXE027 is using at any time should however still be identifiable as the only one "Ready for use" AXE027 cable.

Under PE5, selecting View -> Options -> Serial Port, ticking "Show Port Help Tools..." will reveal a "Scan for USB cable" button which will report the status of AXE027 cable installations and selection as best it can.

PE5 does remember which port it was using, but if the cable is on a different COM port to what it was on, PE5 won't be able to access the PICAXE, will give an error, and it has to be told which port it should now be using.

That should only require telling PE5 which port should be used and does not require uninstalling drivers. Uninstalling drivers is rarely the solution if there are issues which relate to the AXE027 cable or any other device.

Uninstalling drivers does not necessarily uninstall a device Windows knows about and that can compound problems, leaving orphaned devices behind, forcing Windows to allocate a new COM port number when AXE027 drivers are later reinstalled.

The way to resolve such issues is usually to go into Device Manager, show hidden devices, and remove those which aren't required. There will likely be an Environment Variable which needs to be set to actually show all unused devices. If you can tell us which Windows version you have we may be able to provide more detail on how to do that.
 

alhoop

Member
I am using programmer 5.5.3, as I really don't like PE6.
I have never had any trouble with port allocation.
What is the latest 5.5.x version and can it be downloaded - staying away from PE6.
Tnx
Al
 

Steve2381

Senior Member
I am in Win10.
I got fed up with the fact that it refuses to use any of the 3 available USB ports. So I ended up opening hidden devices and uninstalling everything Picaxe related.
But, it still leaves the ghost Axe027 drivers/info somewhere, as upon re-installation, they are still listed, but not working.

No luck with any of the functions in Options, Serial port in the programmer either. Scan for USB cable does nothing.
 

hippy

Technical Support
Staff member
I am in Win10.
I got fed up with the fact that it refuses to use any of the 3 available USB ports. So I ended up opening hidden devices and uninstalling everything Picaxe related.
But, it still leaves the ghost Axe027 drivers/info somewhere, as upon re-installation, they are still listed, but not working.
Did you have the "DEVMGR_SHOW_NONPRESENT_DEVICES" environment variable and have its value set to 1 before opening Device Manager and viewing hidden devices ?

If not Device Manager will not have shown all USB devices which it knows about. Those are probably the ones which remain and reappear after you have removed the ones which are shown -

https://msdn.microsoft.com/en-us/library/windows/hardware/ff553955(v=vs.85).aspx

We would recommend removing all hidden and no longer used AXE027 devices, checking they have gone, rebooting, checking again, before reinstalling any drivers.

It would probably help identify what the problem may be if you could give further details on what you mean by "it refuses to use any of the 3 available USB ports" and "No luck with any of the functions in Options, Serial port in the programmer". Details of what that means, how the problem manifests itself, what messages and error messages are given, what you tried and with what results, will help a lot The more, and more detailed, information you can provide, the easier it will be to see what may be happening.
 

hippy

Technical Support
Staff member
What is the latest 5.5.x version and can it be downloaded
The latest version is 5.5.6. That is a 5.5.5 installation with a patch to take it to 5.5.6.

Those can be downloaded through the "PICAXE Programming Editor 5" link under the "Obsolete" section of our software download page -

www.picaxe.com/Software
 

Steve2381

Senior Member
I upgraded to 5.5.6.
Yes, I did have the "DEVMGR_SHOW_NONPRESENT_DEVICES" open, and set to 1 (looked it up elsewhere).
I will try it again.

No luck... means that if I select a listed AXE027 on my available ports, it then says its in use when you try to upload. Same goes for the one that says communications (or something like that).

In the options menu, I tried pretty much every option. From clear registry, clear program, uninstall... re-install. I think I did eventually try every button.

Long story short, I think I need to get rid of these ghost Axe027's in the computer. I keep having to fall back on Arduinos because I don't have the connection issues with those.
Seems a shame, as the Picaxe is more than capable of the smaller tasks
 
Top