Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Trouble with Data table

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Sat Mar 26, 2005 5:39 am    Post subject: Trouble with Data table Reply with quote

I am trying to use the PC-AT keyboard feature of Bascom and have pretty much
copied the example from "Bascom Programming of Microcontroller with Ease" book.
I have a simple Data table that has the numbers from 0 to 255. This is so I can find out
what the scan code is for my Keypad. I hope that this logic will work.

The error that I am getting I do not understand, so I do not know where to go to correct
the problem. The error is the first line of the code sample below.

I hope someone can see what I am doing wrong

Thank You

Bob Parry


'Error: 11 Line: 20 INPUT, OUTPUT ,0 OR 1 expected [KEYDAT_TABLE=INPUT] in file Keyboard.bas
'
'Setup Crystal

$crystal = 7372800
$baud = 19200

Ddrb = 0 'Port B is Input
'
'
'Query a PC-AT Keypad

'
Config Keyboard = Pinb.1 , Data = Pinb.0 Keydata = Keydata_table

Dim Received_byte As Byte




Print "Hello"

Do

Received_byte = Getatkbd() 'Get a Byte and store in Received_byte
'When NO real Key is pressed
'Result = 0
If Received_byte > 0 Then
Print Received_byte ; Chr(received_byte)
End If
Loop

End 'end program

Keydata_table:

Data 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16,

Data 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32,
Data 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48,
Data 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64,
Data 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80,
Data 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96,
Data 97 , 98 , 99 , 100 , 101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112,
Data 113 , 114 , 115 , 116 , 117 , 118 , 119 , 120 , 121 , 122 , 123 , 124 , 125 , 126 , 127 , 128,
Data 129 , 130 , 131 , 132 , 133 , 134 , 135 , 136 , 137 , 138 , 139 , 140 , 141 , 142 , 143 , 144,
Data 145 , 146 , 147 , 148 , 149 , 150 , 151 , 152 , 153 , 154 , 155 , 156 , 157 , 158 , 159 , 160,
Data 161 , 162 , 163 , 164 , 165 , 166 , 167 , 168 , 169 , 170 , 171 , 172 , 173 , 174 , 175 , 176,
Data 177 , 178 , 179 , 180 , 181 , 182 , 183 , 184 , 185 , 186 , 187 , 188 , 189 , 190 , 191 , 192,
Data 193 , 194 , 195 , 196 , 197 , 198 , 199 , 200 , 201 , 202 , 203 , 204 , 205 , 206 , 207 , 208,
Data 209 , 210 , 211 , 212 , 213 , 214 , 215 , 216 , 217 , 218 , 219 , 220 , 221 , 222 , 223 , 224,
Data 225 , 226 , 227 , 228 , 229 , 230 , 231 , 232 , 233 , 234 , 235 , 236 , 237 , 238 , 239 , 240,
Data 241 , 242 , 243 , 244 , 245 , 246 , 247 , 248 , 249 , 250 , 251 , 252 , 253 , 254 , 255 , 256
'
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sat Mar 26, 2005 10:33 pm    Post subject: Reply with quote

You are missing a comma here................v
Config Keyboard = Pinb.1 , Data = Pinb.0 Keydata = Keydata_table
Back to top
View user's profile Yahoo Messenger
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Sun Mar 27, 2005 12:56 am    Post subject: Reply with quote

Thank You, Thank You.

Little things can certainly choke up the works.

After testing with the comma in the correct place the code works well with
a full AT style keyboard. However when I try to use the separate keypad which
works great on my notebook, I get nothing. When power is connected to the
keypad I get a clock and data signal on my data probe. However when connected
to the Mega16 neither happens. Plugging the normal keyboard into the keypad and
then to the Mega16 the keyboard works, but no keypad.

Any suggestions? I really do not want to use a full size keyboard and if I can make the
keypad work then everything else is easy.

Confused
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sun Mar 27, 2005 2:29 am    Post subject: Reply with quote

I guess you are using keyboards / keypads with PS2 style connectors on them (the kind used on keyboards and mice). I suspect the problem is the difference between keyboards and mice and that your numeric keypad is communicating in "mouse fashion" instead of "keyboard fashion".

What I mean by this is, after power-on, keyboards tend to send data automatically anytime a key is pressed. They don't have to be "talked to" or initialized in any way. On the other hand, the natural state for a mouse after power-on is to not send any data (mice have to be communicated to and initialized before it will send any data).

I've not interfaced any PS2 keyboards to an AVR but I have interfaced mice. For mice, you have to know the codes to send in order to initialize it. After that, it will spit out information for any movement or button action.

For your numeric keypad, I have no idea what byte packets it may need for initialization. Here is a link to some good information but you'll need to Google around for more specifics on numeric keypad initialization. The PS2 Mouse/Keyboard Protocol

Something else you might try (since your AVR can receive these PS2 signals). Attach some wires to your small keypad and AVR and then plug the keypad into your laptop. Let the AVR evesdrop on the byte packets the laptop sends to initialize and what the keypad sends back (print these out). You can then use that data to initialize the the keypad via the AVR when the two are connected directly. Unfortunately there'd be some guesswork involved for who was sending what for intitialization (the laptop or the keypad).
Back to top
View user's profile Yahoo Messenger
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Sun Mar 27, 2005 3:15 am    Post subject: Reply with quote

Your thought about sending an initialization string makes sense. I will google around
and see what I can come up with.

Thank you for all the help

Bob Parry
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum