ColorPal Only works on 18M2? (at 8 MHz)

kando

Senior Member
Hi, I've been pulling my hair out with this one. I'm using the code from WestAust55. Well a chopped down version of it. This only gives a transition RGB then an input of RGB and displays it on the terminal in the PE.
It seems only to work on the 18M2. I have tried the same code adjusting the Picaxe chip to 14M2,20X2,and 40X2 but it refuses to do the same thing.
It all seems fine in each on the simulator. It just hangs waiting for the colorPal to input. Weird!
Any ideas?
Kando.
Code:
[color=Navy]#picaxe [/color][color=Black]18M2[/color][color=Green];14M2;20X2;40X2[/color]
[color=Navy]#no_data[/color]
[color=Green];#no_table[/color]
[color=Navy]#terminal 4800[/color][color=Green];9600;for 20 and 40[/color]

[color=Blue]SYMBOL [/color][color=Black]sio [/color][color=DarkCyan]= [/color][color=Blue]C.0 [/color][color=Green]; Pin used for Serial I/O com with the ColorPAL.[/color]
[color=Blue]SYMBOL [/color][color=Black]sinp [/color][color=DarkCyan]= [/color][color=Purple]pinC.0 [/color][color=Green]; Same pin but definition as an input for tests.[/color]
[color=Blue]SYMBOL [/color][color=Black]red [/color][color=DarkCyan]= [/color][color=Purple]w1 [/color][color=Green]; Reconstructed RGB values received from ColorPAL.[/color]
[color=Blue]SYMBOL [/color][color=Black]grn [/color][color=DarkCyan]= [/color][color=Purple]w2[/color]
[color=Blue]SYMBOL [/color][color=Black]blu [/color][color=DarkCyan]= [/color][color=Purple]w3[/color]
[color=Blue]SYMBOL [/color][color=Black]rd1 [/color][color=DarkCyan]= [/color][color=Purple]b8 [/color][color=Green]; Each of the raw three colour bytes for RGB as received[/color]
[color=Blue]SYMBOL [/color][color=Black]rd2 [/color][color=DarkCyan]= [/color][color=Purple]b9[/color]
[color=Blue]SYMBOL [/color][color=Black]rd3 [/color][color=DarkCyan]= [/color][color=Purple]b10[/color]
[color=Blue]SYMBOL [/color][color=Black]gn1 [/color][color=DarkCyan]= [/color][color=Purple]b11[/color]
[color=Blue]SYMBOL [/color][color=Black]gn2 [/color][color=DarkCyan]= [/color][color=Purple]b12[/color]
[color=Blue]SYMBOL [/color][color=Black]gn3 [/color][color=DarkCyan]= [/color][color=Purple]b13[/color]
[color=Blue]SYMBOL [/color][color=Black]bl1 [/color][color=DarkCyan]= [/color][color=Purple]b14[/color]
[color=Blue]SYMBOL [/color][color=Black]bl2 [/color][color=DarkCyan]= [/color][color=Purple]b15[/color]
[color=Blue]SYMBOL [/color][color=Black]bl3 [/color][color=DarkCyan]= [/color][color=Purple]b16[/color]
[color=Blue]SYMBOL [/color][color=Black]baud [/color][color=DarkCyan]= [/color][color=Blue]T4800_8 [/color][color=Green]; set baud rate[/color]

[color=Black]Init:[/color]
[color=Blue]PAUSE [/color][color=Navy]10000 [/color][color=Green]; give you time to clear chip if problems and open the PE terminal window[/color]
[color=Black]go1:[/color]
[color=Blue]SERTXD ([/color][color=Red]"enter a 'x' to start"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
SERRXD [/color][color=Purple]b26[/color]
[color=Blue]IF [/color][color=Purple]b26 [/color][color=DarkCyan]<> [/color][color=Red]"x" [/color][color=Blue]THEN [/color][color=Black]go1 [/color][color=Green]; loop and wait until command received[/color]

[color=Blue]GOSUB [/color][color=Black]CP_Reset [/color][color=Green]; reset the ColorPAL and enter direct command mode.[/color]
[color=Blue]SEROUT [/color][color=Black]sio, baud, [/color][color=Blue]([/color][color=Red]"= R t12 G t12 B !"[/color][color=Blue]) [/color][color=Green];transition from red to green to blue on LEDs[/color]
[color=Blue]pause [/color][color=Navy]6000[/color]


[color=Black]go3:[/color]
[color=Blue]SERTXD ([/color][color=Red]"enter a 'z' to start"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
SERRXD [/color][color=Purple]b26[/color]
[color=Blue]IF [/color][color=Purple]b26 [/color][color=DarkCyan]<> [/color][color=Red]"z" [/color][color=Blue]THEN [/color][color=Black]go3 [/color][color=Green]; loop and wait until command received[/color]
[color=Blue]SEROUT [/color][color=Black]sio, baud, [/color][color=Blue]([/color][color=Red]"= (01 $ m) !"[/color][color=Blue]) [/color][color=Green]; perform a single multi-colour scan[/color]
[color=Blue]SERIN [/color][color=Black]sio, baud, rd1, rd2, rd3, gn1, gn2, gn3, bl1, bl2, bl3[/color]
[color=Blue]SERTXD ([/color][color=Red]"RGB = "[/color][color=Black], rd1,[/color][color=Red]" "[/color][color=Black], rd2,[/color][color=Red]" "[/color][color=Black], rd3,[/color][color=Red]" "[/color][color=Black], gn1,[/color][color=Red]" "[/color][color=Black], gn2,[/color][color=Red]" "[/color][color=Black], gn3,[/color][color=Red]" "[/color][color=Black], bl1,[/color][color=Red]" "[/color][color=Black], bl2,[/color][color=Red]" "[/color][color=Black], bl3, [/color][color=Blue]cr[/color][color=Black], [/color][color=Blue]lf[/color][color=Black], [/color][color=Blue]cr[/color][color=Black], [/color][color=Blue]lf)


end[/color]

[color=Black]CP_Reset:[/color]
[color=Blue]LOW [/color][color=Black]sio [/color][color=Green];Pull sio low to eliminate any residual charge.[/color]
[color=Blue]INPUT [/color][color=Black]sio [/color][color=Green];Return pin to input.[/color]
[color=Blue]DO UNTIL [/color][color=Black]sinp [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Black]: [/color][color=Blue]LOOP [/color][color=Green];Wait for pin to be pulled high by ColorPAL.[/color]
[color=Blue]LOW [/color][color=Black]sio [/color][color=Green];Pull pin low.[/color]
[color=Blue]PAUSE [/color][color=Navy]80 [/color][color=Green];Keep low for 80ms to enter Direct mode.[/color]
[color=Blue]INPUT [/color][color=Black]sio [/color][color=Green];Return pin to input.[/color]
[color=Blue]PAUSE [/color][color=Navy]10 [/color][color=Green];Pause another 10ms[/color]
[color=Blue]RETURN[/color]
 
Last edited by a moderator:

hippy

Technical Support
Staff member
It could be that something 'PICAXE 18M2 specific' needs changing in the program code; probably 'sio', 'siop' and 'baud' definitions and perhaps also operating speeds.

Westaust55 still frequents the forum so may come along and be able to advise. For others it might be worth providing a link to the ColorPal or explaining what it is and and any links to where you found the code may be useful in providing help.
 

westaust55

Moderator
The ColorPAL should work on any PICAXE chip.

For your 14M2 test for example, can you please provide the schematic showing which pin was used and post your program (specifically the section for the IO pin assignments).
Also a photo or sketch showing which board if other than a breadbaord please.

You seem to have a versions of my tutorial modified by others.

The original tutorial (that above is modified with no ack to myself) covering other PIXAXE parts also is found here:
http://www.picaxeforum.co.uk/showthread.php?20880-Using-the-Parallax-ColorPAL-Colour-Sensor-module-with-PICAXE-chips&highlight=ColorPAL
 
Last edited:

kando

Senior Member
Are you using a project board with a 10k pulldown pre-fitted on C.0?
I'm using the development board axe 091. the data line goes straight to the Colorpal from the pin c.0. It works like this for the 18M2 but not the others.


I have since taken a small breadboard, fitted up with download stuff placed a 14M2 loaded with the code and it doesn't work.
However, I have noticed that at the first "x" input to get the transition started there is a very quick flash of the LEDs on the colorpal then nothing.
So am I right in guessing it has something to do with the input/output?

I have just tried this code in a 08M2 and with pin C.1 and it works.

So the question is still, "what is wrong with the other chips?"
 
Last edited:

westaust55

Moderator
I'm using the development board axe 091. the data line goes straight to the Colorpal from the pin c.0. It works like this for the 18M2 but not the others.


I have since taken a small breadboard, fitted up with download stuff placed a 14M2 loaded with the code and it doesn't work.
However, I have noticed that at the first "x" input to get the transition started there is a very quick flash of the LEDs on the colorpal then nothing.
So am I right in guessing it has something to do with the input/output?
Confirmed that it will not operate with the 14M2 at 8 MHz clock speed.
See post 20 in my original thread (placed there to keep like information together).
http://www.picaxeforum.co.uk/showthread.php?20880-Using-the-Parallax-ColorPAL-Colour-Sensor-module-with-PICAXE-chips/page2

Post 21 on the next page of same thread has the 28X2 solution.


With respect to the "modified" .pdf you posted, if you are using the programs and information for your own work elsewhere, then you should be acknowledging the source of your information.
Also good to point others using your information to the PICAXE forum in general and the thread where you sourced the basis of your work.

Regards
WestAust55
 
Last edited:

kando

Senior Member
I would certainly acknowledge your work if I used it. I would also ask permission to use it if it were going anywhere else other than into my personal knowledge. Have deleted that post.. apologies to you and thank you for the information about the setfreq I was hoping that you could answer this and I was right. Again apoligies and thank you.
 

kando

Senior Member
Here is the 14M2 code that now works with the help from Westaust55

Code:
[color=Navy]#picaxe [/color][color=Black]14M2[/color]
[color=Navy]#no_data[/color]
[color=Green];Original Author.... WestAust55
;This is part of that code
;#no_table[/color]
[color=Navy]#terminal 19200[/color]

[color=Blue]SYMBOL sio [/color][color=DarkCyan]= [/color][color=Blue]C.0 [/color][color=Green]; Pin used for Serial I/O com with the ColorPAL.[/color]
[color=Blue]SYMBOL [/color][color=Purple]sinp [/color][color=DarkCyan]= [/color][color=Purple]pinC.0 [/color][color=Green]; Same pin but definition as an input for tests.[/color]
[color=Blue]SYMBOL [/color][color=Purple]red [/color][color=DarkCyan]= [/color][color=Purple]w1 [/color][color=Green]; Reconstructed RGB values received from ColorPAL.[/color]
[color=Blue]SYMBOL [/color][color=Purple]grn [/color][color=DarkCyan]= [/color][color=Purple]w2[/color]
[color=Blue]SYMBOL [/color][color=Purple]blu [/color][color=DarkCyan]= [/color][color=Purple]w3[/color]
[color=Blue]SYMBOL [/color][color=Purple]rd1 [/color][color=DarkCyan]= [/color][color=Purple]b8 [/color][color=Green]; Each of the raw three colour bytes for RGB as received[/color]
[color=Blue]SYMBOL [/color][color=Purple]rd2 [/color][color=DarkCyan]= [/color][color=Purple]b9[/color]
[color=Blue]SYMBOL [/color][color=Purple]rd3 [/color][color=DarkCyan]= [/color][color=Purple]b10[/color]
[color=Blue]SYMBOL [/color][color=Purple]gn1 [/color][color=DarkCyan]= [/color][color=Purple]b11[/color]
[color=Blue]SYMBOL [/color][color=Purple]gn2 [/color][color=DarkCyan]= [/color][color=Purple]b12[/color]
[color=Blue]SYMBOL [/color][color=Purple]gn3 [/color][color=DarkCyan]= [/color][color=Purple]b13[/color]
[color=Blue]SYMBOL [/color][color=Purple]bl1 [/color][color=DarkCyan]= [/color][color=Purple]b14[/color]
[color=Blue]SYMBOL [/color][color=Purple]bl2 [/color][color=DarkCyan]= [/color][color=Purple]b15[/color]
[color=Blue]SYMBOL [/color][color=Purple]bl3 [/color][color=DarkCyan]= [/color][color=Purple]b16[/color]
[color=Blue]SYMBOL baud [/color][color=DarkCyan]= [/color][color=Blue]T4800_16 [/color][color=Green]; set baud rate[/color]

[color=Black]Init:[/color]
[color=Blue]setfreq m16
PAUSE [/color][color=Navy]6000 [/color][color=Green]; give you time to clear chip if problems and open the PE terminal window[/color]
[color=Black]go1:[/color]
[color=Blue]SERTXD ([/color][color=Red]"enter a 'x' to start"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
SERRXD [/color][color=Purple]b26[/color]
[color=Blue]IF [/color][color=Purple]b26 [/color][color=DarkCyan]<> [/color][color=Red]"x" [/color][color=Blue]THEN [/color][color=Black]go1 [/color][color=Green]; loop and wait until command received[/color]

[color=Blue]GOSUB [/color][color=Black]CP_Reset [/color][color=Green]; reset the ColorPAL and enter direct command mode.[/color]
[color=Blue]SEROUT sio[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Red]"= R t12 G t12 B !"[/color][color=Blue]) [/color][color=Green];transition from red to green to blue on LEDs[/color]

[color=Black]go3:[/color]
[color=Blue]SERTXD ([/color][color=Red]"enter a 'z' to start"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
SERRXD [/color][color=Purple]b26[/color]
[color=Blue]IF [/color][color=Purple]b26 [/color][color=DarkCyan]<> [/color][color=Red]"z" [/color][color=Blue]THEN [/color][color=Black]go3 [/color][color=Green]; loop and wait until command received[/color]
[color=Blue]SEROUT sio[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Red]"= (01 $ m) !"[/color][color=Blue]) [/color][color=Green]; perform a single multi-colour scan[/color]
[color=Blue]SERIN sio[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Purple]rd1[/color][color=Black], [/color][color=Purple]rd2[/color][color=Black], [/color][color=Purple]rd3[/color][color=Black], [/color][color=Purple]gn1[/color][color=Black], [/color][color=Purple]gn2[/color][color=Black], [/color][color=Purple]gn3[/color][color=Black], [/color][color=Purple]bl1[/color][color=Black], [/color][color=Purple]bl2[/color][color=Black], [/color][color=Purple]bl3[/color]
[color=Blue]SERTXD ([/color][color=Red]"RGB = "[/color][color=Black], [/color][color=Purple]rd1[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]rd2[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]rd3[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]gn1[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]gn2[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]gn3[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]bl1[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]bl2[/color][color=Black],[/color][color=Red]" "[/color][color=Black], [/color][color=Purple]bl3[/color][color=Black], [/color][color=Blue]cr[/color][color=Black], [/color][color=Blue]lf[/color][color=Black], [/color][color=Blue]cr[/color][color=Black], [/color][color=Blue]lf)

end[/color]

[color=Black]CP_Reset:[/color]
[color=Blue]SERTXD ([/color][color=Red]"Starting Reset -" [/color][color=Blue])
  LOW sio                   [/color][color=Green];Pull sio low to eliminate any residual charge.
  [/color][color=Blue]INPUT sio                 [/color][color=Green];Return pin to input.
  [/color][color=Blue]DO UNTIL [/color][color=Purple]sinp [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Black]: [/color][color=Blue]LOOP  [/color][color=Green];Wait for pin to be pulled high by ColorPAL.
  [/color][color=Blue]LOW sio                   [/color][color=Green];Pull pin low.
  [/color][color=Blue]PAUSE [/color][color=Navy]160                  [/color][color=Green];Keep low for 80ms to enter Direct mode.
  [/color][color=Blue]INPUT sio                 [/color][color=Green];Return pin to input.
  [/color][color=Blue]PAUSE [/color][color=Navy]20                  [/color][color=Green];Pause another 10ms[/color]
[color=Blue]SERTXD ([/color][color=Red]"completed Reset"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
  RETURN[/color]
 
Last edited:
Top