Keyboard PS2 to Parallel out

Basrad

Member
Hi. please bear with me, as im very new to this, and a little confused easily..

I want to use the output pins on my 18M chip to output a 5 or 8bit parallel output..

For the input i'm using a ps2 keyboard

I've used the KBin command, and also used the reference table from the keyin.bas sample.

I then store the keyvalue into either b0 or b1 and then let pins = b0 pause 1 sec then set them all to 0 again...

PROblem = when simulating only output 0,1,2,3,4,5, all go high. which ever keyboard key is pressed the output is the same.

I tried using if keyvalue = $ (key) then let pins = (my own binary out)

but this does the same... Any advice or sample codes to try would make my day :)

Many thanks all... Very sorry if this is already in a post, I did have a good look
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE Forum.

If you post your code then perhaps others can see what is going wrong or run it for themselves to see if they get the same results as you do.

[Moved to Active Forum]
 
Last edited:

Chavaquiah

Senior Member
Hello.

You say you're using KBIN and a Picaxe 18M. The manual says KBIN is only for the X1 and X2 variants, not for the 18M. Could you check this?

Also, I'm not sure you can use the lookup table as the keyin.bas sample shows. See the following thread:
http://www.picaxeforum.co.uk/showthread.php?t=11977

Any Eeprom data specified using EEPROM or DATA commands will not be loaded to the 18M; all 18M Eeprom data will be initialised to zero. The 18M has shared code and data, not separate code and data areas. READ and WRITE commands will work but must operate in accordance with the shared code and data constraints ( as per 08M etc ).
You probably should check that keyin (not kbin) is working as intended first. Perhaps you could issue a debug command after reading keyvalue, just to check.

Or send the result unaltered by a lookup table. Did you try something similar to:

Code:
main:
	keyin
	pins = keyvalue
	goto main
 

Basrad

Member
Wow, thanks for the super fast replys..

Well i'm afraid I didnt save the code, as thought i should start from new..

So 1 problem I had was the command was'nt good to use with my 18M

I have tried the code.

main:
keyin
let pins = keyvalue
pause 1000
goto main

But none of the outputs go high when I press a key.. They are all low (in the simulator)
 

Chavaquiah

Senior Member
You're right, it doesn't work in the simulator (at least in the current version). The key value is placed in INFRA (probably the same register as KEYVALUE) but then B0 = INFRA or B0 = KEYVALUE or yet OUTPINS = KEYVALUE all get zero.

It works as expected if one changes the Picaxe model to 18A or 18X.

Likely an issue with the simulator. Can you test on a real 18M?
 

Basrad

Member
Thank you all very much

Built the hardware and flashed the 18M with the code which was not working on the simulator.. All seems to work perfectly.

Project complete :)
 
Top