Array of bits to shiftout
Hi Everyone,
Im pretty new to the whole basic stamp thing, but have been programming in various laguages for many years (unfortunately none of which were basic). Anyways, im working on restoring a pinball machine which has ~45 lights on it and ~23 switches, as well as some 50v solenoids, all to be controlled by a BS2sx chip. I have made a controller board of 74hc4094's for my lights which i have gotten working using a for-loop. The place where im storing the lights status (0 or 1) is an array of bits. Heres what i want to do: use shiftout to dump that array of bits to my light controller board, however it doesnt seem to be working. Here is my for loop to get a better idea:
EDIT: i should mention here that CLOCK, SERIAL, Strobe are PIN vars (although they are consts in the below example) and MAX_PINS is a const currently defined as 45 (which i should probably move up to 48)
Ideally i want to replace it with something like this:
which im hoping will be well faster, however its the passing of pinStatus to shifout which is giving me grief. Ive tried a few different combinations such as:
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus]
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)]
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)\16] (to get only the first 16 statuses)
and even
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)\16, pinStatus(0)>>16\16, pinStatus(0)>>32\16]
Can anyone help?!? I can get it working if i just use 65535 instead of the pinStatus crazyness, so i know my controller board is fine.
on a side note i have a usb->serial adapter (chipset HL-340), however it only detects the stamp *some* of the time, although echo and the other thing come back positive - any ideas?
Cheers
Im pretty new to the whole basic stamp thing, but have been programming in various laguages for many years (unfortunately none of which were basic). Anyways, im working on restoring a pinball machine which has ~45 lights on it and ~23 switches, as well as some 50v solenoids, all to be controlled by a BS2sx chip. I have made a controller board of 74hc4094's for my lights which i have gotten working using a for-loop. The place where im storing the lights status (0 or 1) is an array of bits. Heres what i want to do: use shiftout to dump that array of bits to my light controller board, however it doesnt seem to be working. Here is my for loop to get a better idea:
pinStatus VAR Bit(MAX_PINS) FOR loopCounter = 0 TO (MAX_PINS - 1) currentPin = (MAX_PINS - 1) - loopCounter IF (pinStatus(currentPin) = 0) THEN SERIAL = IsOff ELSE SERIAL = IsOn ENDIF CLOCK = 1 CLOCK = 0 NEXT PULSOUT Strobe,1
EDIT: i should mention here that CLOCK, SERIAL, Strobe are PIN vars (although they are consts in the below example) and MAX_PINS is a const currently defined as 45 (which i should probably move up to 48)
Ideally i want to replace it with something like this:
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus] PULSOUT Strobe,1
which im hoping will be well faster, however its the passing of pinStatus to shifout which is giving me grief. Ive tried a few different combinations such as:
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus]
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)]
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)\16] (to get only the first 16 statuses)
and even
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse]pinStatus(0)\16, pinStatus(0)>>16\16, pinStatus(0)>>32\16]
Can anyone help?!? I can get it working if i just use 65535 instead of the pinStatus crazyness, so i know my controller board is fine.
on a side note i have a usb->serial adapter (chipset HL-340), however it only detects the stamp *some* of the time, although echo and the other thing come back positive - any ideas?
Cheers
Comments
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse] theWords1, theWords2, theWords3\13 ]
or
SHIFTOUT 1, 2, MSBPRE, [noparse][[/noparse] theWords(0), theWords(1), theWords(2)\13 ]
The \13 would only be needed if you still want to use only 45 bits.
I might just stick with the loop for now - it is probably the fastest, and in a game application, speed is everything!
or will i have to write a chunk of code to insert each bit into the 'bit' array
also, the above suggested code doesnt work if i use
it whinges on the 'bit' saying 'expected a variable modifier.
Post Edited (poho) : 2/12/2009 9:59:14 AM GMT