PICAXE 20X2 problem

Peterrey

New Member
Any help would be gratefully received...

I have written a program and developed a circuit to adapt the entry in the PICAXE Manual 1 FAQ section regarding extending the number of output ports available. The circuit is built on a standard REV-ED PICAXE 20 PCB, and consists of 6 red/green leds (with associated resistors, of course) connected across adjacent ports. 4 are on port B (0/1, 2/3, 4/5, 6/7) and 2 are on port C (0/1, 2/3). The serial input will be on port c.7. All the leds light correctly; however, I require the leds to basically show the binary equivalent of the input where a green led is equivalent of logic 0 and a red led is equivalent to logic 1. I have tried the program in simulated mode outside of the PCB and it appears to work correctly in that when you enter a number in the simulator it is carried over to the program as you enter it. However, in order to test it downloaded onto the PCB, it appears that only the lowest significant bits register (0-9) when using SERRXD command. For example, if you enter 45 in the terminal window, only the '5' registers. I can't get anything sensible from the assembly at present; I have tried using word variables without luck. The only way I managed to get something sensible out of it was by adding the 'let b1 = b3 - 33' command and using ASCII characters (from !(33)to '(96)) in the terminal screen. When operated this way I can get all 6 leds to indicate exactly as required. However, I am not keen to use this method when the assembly is completed as the driver circuit will consist of a 40X2, and it was easier to just have this output a number to send to this 20X2 and that should work according to the manual. Putting the '#' in front of the input variable in an attempt to get a raw input doesn't seem to have any effect at all. Help...

Code:
'This program is to control the LOP indicators on the new Smithfield Panel

'b1 = 0 - 15 for Points 6, 7, 8, 9 only
'b1 = 16 - 31 adding Point 10 only
'b1 = 32 - 63 adding point 24 only

'Refer to ASCII table - codes begin at 33 (!) and end at 96 (`) - for characters to send when using SERRXD


#picaxe 20X2

let dirsb = %11111111
let dirsc = %00001111

let pinsc = 5
let pinsb = 85
let b2 = 0
disconnect 'this is required for the serrxd command

main:	
	serrxd b1 'use this command to test module
	'serin c.7,N4800,b3 'use this command when running normally
	pause 10
	'let b1 = b3 - 33
	if b1 = b2 then goto main
	if b1 >= 64 then goto main
	if b1 >= 0 and b1 <= 15 then let pinsc = 10 : let b2 = b1 : goto low_four : endif
	if b1 >= 16 and b1 <= 31 then let pinsc = 9 : let b2 = b1 : let b1 = b1 - 16 : goto low_four : endif
	if b1 >= 32 and b1 <= 47 then let pinsc = 6 : let b2 = b1 : let b1 = b1 - 32 : goto low_four : endif
	if b1 >= 48 and b1 <= 63 then let pinsc = 5 : let b2 = b1 : let b1 = b1 - 48 : goto low_four : endif
	if b1 = 99 then test_over

	
	
low_four:

	if b1 = 15 then let pinsb = 170 : endif
	if b1 = 14 then let pinsb = 169 : endif
	if b1 = 13 then let pinsb = 166 : endif
	if b1 = 12 then let pinsb = 165 : endif
	if b1 = 11 then let pinsb = 154 : endif
	if b1 = 10 then let pinsb = 153 : endif
	if b1 = 9 then let pinsb = 150 : endif
	if b1 = 8 then let pinsb = 149 : endif
	if b1 = 7 then let pinsb = 106 : endif
	if b1 = 6 then let pinsb = 105 : endif
	if b1 = 5 then let pinsb = 102: endif
	if b1 = 4 then let pinsb = 101: endif
	if b1 = 3 then let pinsb = 90 : endif
	if b1 = 2 then let pinsb = 89 : endif
	if b1 = 1 then let pinsb = 86 : endif
	if b1 = 0 then let pinsb = 85 : endif
	sertxd (#b1)
	goto main
	
test_over: 'this is  only needed when using serrxd command
	pause 100
	reconnect
	pause 100
	let pinsb = 85
	let pinsc = 5
	pause 100
	stop
 

hippy

Ex-Staff (retired)
For example, if you enter 45 in the terminal window, only the '5' registers.
The problem is that you are sending multiple characters from Terminal with ASCII encoding when the program is expecting single byte values. The Terminal cannot communicate with it in the same way another PICAXE driving this one would.
 

Peterrey

New Member
Many thanks to those who replied...

Thank you for your reply; I thought I had considered the 'one byte' issue but had hoped that by removing the two extra high bits I could control it in the standard way. What I have done now is to add a small portion of extra code to the main program on the controlling unit (a circuit using a 40X2) that writes the numbers 33 to 96 into the 63 EEPROM locations starting at 0. An additional couple of lines now retrieves the particular ASCII code from the location that corresponds with the number from 0 to 63 and transmits this to the code below running on the 20X2. I have high hopes that this will work correctly, but I am not in a position to test it until the installation is complete.

Any help would be gratefully received...

I have written a program and developed a circuit to adapt the entry in the PICAXE Manual 1 FAQ section regarding extending the number of output ports available. The circuit is built on a standard REV-ED PICAXE 20 PCB, and consists of 6 red/green leds (with associated resistors, of course) connected across adjacent ports. 4 are on port B (0/1, 2/3, 4/5, 6/7) and 2 are on port C (0/1, 2/3). The serial input will be on port c.7. All the leds light correctly; however, I require the leds to basically show the binary equivalent of the input where a green led is equivalent of logic 0 and a red led is equivalent to logic 1. I have tried the program in simulated mode outside of the PCB and it appears to work correctly in that when you enter a number in the simulator it is carried over to the program as you enter it. However, in order to test it downloaded onto the PCB, it appears that only the lowest significant bits register (0-9) when using SERRXD command. For example, if you enter 45 in the terminal window, only the '5' registers. I can't get anything sensible from the assembly at present; I have tried using word variables without luck. The only way I managed to get something sensible out of it was by adding the 'let b1 = b3 - 33' command and using ASCII characters (from !(33)to '(96)) in the terminal screen. When operated this way I can get all 6 leds to indicate exactly as required. However, I am not keen to use this method when the assembly is completed as the driver circuit will consist of a 40X2, and it was easier to just have this output a number to send to this 20X2 and that should work according to the manual. Putting the '#' in front of the input variable in an attempt to get a raw input doesn't seem to have any effect at all. Help...

Code:
'This program is to control the LOP indicators on the new Smithfield Panel

'b1 = 0 - 15 for Points 6, 7, 8, 9 only
'b1 = 16 - 31 adding Point 10 only
'b1 = 32 - 63 adding point 24 only

'Refer to ASCII table - codes begin at 33 (!) and end at 96 (`) - for characters to send when using SERRXD


#picaxe 20X2

let dirsb = %11111111
let dirsc = %00001111

let pinsc = 5
let pinsb = 85
let b2 = 0
disconnect 'this is required for the serrxd command

main:	
	serrxd b1 'use this command to test module
	'serin c.7,N4800,b3 'use this command when running normally
	pause 10
	'let b1 = b3 - 33
	if b1 = b2 then goto main
	if b1 >= 64 then goto main
	if b1 >= 0 and b1 <= 15 then let pinsc = 10 : let b2 = b1 : goto low_four : endif
	if b1 >= 16 and b1 <= 31 then let pinsc = 9 : let b2 = b1 : let b1 = b1 - 16 : goto low_four : endif
	if b1 >= 32 and b1 <= 47 then let pinsc = 6 : let b2 = b1 : let b1 = b1 - 32 : goto low_four : endif
	if b1 >= 48 and b1 <= 63 then let pinsc = 5 : let b2 = b1 : let b1 = b1 - 48 : goto low_four : endif
	if b1 = 99 then test_over

	
	
low_four:

	if b1 = 15 then let pinsb = 170 : endif
	if b1 = 14 then let pinsb = 169 : endif
	if b1 = 13 then let pinsb = 166 : endif
	if b1 = 12 then let pinsb = 165 : endif
	if b1 = 11 then let pinsb = 154 : endif
	if b1 = 10 then let pinsb = 153 : endif
	if b1 = 9 then let pinsb = 150 : endif
	if b1 = 8 then let pinsb = 149 : endif
	if b1 = 7 then let pinsb = 106 : endif
	if b1 = 6 then let pinsb = 105 : endif
	if b1 = 5 then let pinsb = 102: endif
	if b1 = 4 then let pinsb = 101: endif
	if b1 = 3 then let pinsb = 90 : endif
	if b1 = 2 then let pinsb = 89 : endif
	if b1 = 1 then let pinsb = 86 : endif
	if b1 = 0 then let pinsb = 85 : endif
	sertxd (#b1)
	goto main
	
test_over: 'this is  only needed when using serrxd command
	pause 100
	reconnect
	pause 100
	let pinsb = 85
	let pinsc = 5
	pause 100
	stop
 
Top