7Seg-DB Daughterboard with BS2
Richard McCall
Posts: 6
I purchased the Parallax 7Seg-DB Daughterboard and the adaptor that allows it to be used with a regular breadboard.
Although I realize that it is made to take advantage of the BS2pe motherboard and its additional processors, I'm wondering if there is not some further documentation that will help me program the unit using Basic. The exisiting documentation treats only high level programming with much of the interface uploaded in hex to the motherboard.
The schematic is somewhat helpful in figuring out the display driver, but I would be helped if there were some documentation on the timing and sequence of commands (I've been using SHIFTOUT) as well as the codes associated with each digit.
Has anyone successfully programmed this unit using basic (Parallax or PICBasicPro) or know of any further resources?
Thanks,
Rick
Although I realize that it is made to take advantage of the BS2pe motherboard and its additional processors, I'm wondering if there is not some further documentation that will help me program the unit using Basic. The exisiting documentation treats only high level programming with much of the interface uploaded in hex to the motherboard.
The schematic is somewhat helpful in figuring out the display driver, but I would be helped if there were some documentation on the timing and sequence of commands (I've been using SHIFTOUT) as well as the codes associated with each digit.
Has anyone successfully programmed this unit using basic (Parallax or PICBasicPro) or know of any further resources?
Thanks,
Rick
Comments
Initialization:
1. Raise /PWM.
2. Raise SCK.
3. Pulse RCK four times. This clears the anode driver shift register to all 1s.
4. Lower /PWM.
For each digit, in sequence:
1. Using SCK and D, clock in the segments for the first digit (1 = bright; 0 = dark). Leave SCK high for all but the first digit in every group of four.
2. Pulse RCK. This outputs the segment data just clocked in and shifts SCK into the anode driver shift register. Any "0" previously shifted in will advance to the next digit.
3. Return SCK low, if it's still high.
4. Repeat.
Following this procedure, the anode driver shift register will change state like so after each digit:
1110 <- SCK = 0
1101 <- SCK = 1
1011 <- SCK = 1
0111 <- SCK = 1
1110 <- SCK = 0
...
The use of SCK as an input to the anode driver shift register may preclude using SHIFTOUT for all eight bits of the segment data. You may have to use it for 7 bits and bit-bang the last one in order to keep SCK high at the end.
Whether a BS2 program can execute fast enough not to cause noticeable flicker among the digits remains to be seen. If you are successful, please post your code on the forum.
Good luck!
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Rick
Using "SHIFTOUT D,SCK,1,[noparse][[/noparse]$E7]," for example, I can easily transfer the segments to the 74HCT595. Of course, the same number appears in each digit when RCK is pulsed.
I'm not sure how the proper state gets transferred to SCK so that it can be sent to the anode driver. If I use "SHIFTOUT, SCK,RCK,1,[noparse][[/noparse]%1101]," for example, a particular digit is selected. However, depending on where this command appears, it either corrupts the segment data or produces uneven intensities on the digits.
Could you say a bit more about how to clock the data into the 74HCT595 so that the SCK line contains the proper data to send to the anode driver? How many bits can the register hold?
Thanks for your help and patience.
Rick
This is untested code and relies on Char being a Byte array of length four, and D, SCK, and RCK being defined appropriately using PIN commands.
-Phil
Rick
Thanks again for your your helpful suggestions.
Rick
_________________________________________________________________________________
' {$STAMP BS2}
' {$PBASIC 2.5}
'~~~~~~~Definitions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RCK PIN 6 'Parallax adapter pin A (RCK)
D PIN 7 'Parallax adapter pin B (DI)
SCK PIN 5 'Parallax adapter pin C (SCK)
PW PIN 4 'Parallax adapter pin D (PWM) 120 K Resistor
digit VAR Byte
i VAR Byte
Char VAR Byte(4)
number VAR Byte
cnt VAR Word
digt VAR Byte
lsb VAR Byte
t VAR Byte
'~~~~~~~~INITIALIZATION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HIGH PW
HIGH SCK
FOR i = 1 TO 4
PULSOUT RCK,1
NEXT
LOW PW
'~~~~~~~~~MAIN PROGRAM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Counter:
cnt = 0 'Initialize Cnt to 0
NXT:
digit = cnt DIG 3 'Get 1000s digit
GOSUB CONVERT 'Get segments to turn on
Char(0) = number 'Display pattern for 1000s digit
digit = cnt DIG 2 'Get 100s digit
GOSUB CONVERT 'Get segments to turn on
Char(3) = number 'Display pattern for 100s digit
digit = cnt DIG 1 'Get 10s digit
GOSUB CONVERT 'Get segments to turn on
Char(2) = number 'Display pattern for 10s digit
digit = cnt DIG 0 'Get 1s digit
GOSUB CONVERT 'Get segments to turn on
Char(1) = number 'Display pattern for 1s digit
GOSUB display 'Display number on Parallax 7-Seg Daughterboard
cnt = cnt + 1 'Increment Cnt
IF cnt > 9999 THEN Counter
GOTO NXT
'~~~~~~~~~~~~DISPLAY SUBROUTINE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Display:
IF cnt < 10 THEN char(0)= 0:char(2) = 0:char(3) = 0 'Suppress leading zeros
IF cnt < 100 THEN char(0) = 0:char(3) = 0
IF cnt < 1000 THEN char(0) = 0
FOR t = 1 TO 200 'Timing loop for counter
IF (digt) THEN 'For digits 1, 2,and 3,
lsb = Char(digt)& 1 'save LSB in variable y
SHIFTOUT d,SCK,1,[noparse][[/noparse]Char(digt) >> 1\7] 'Shift byte 1 bit to right and shift result into register
D = lsb 'Bang saved bit in
HIGH SCK 'Take SCK high
ELSE
SHIFTOUT D,SCK,1,[noparse][[/noparse]Char(digt)] 'For digit 0, shift byte into register
ENDIF
PULSOUT RCK,1 'Send clock pulse
LOW SCK 'Take SCK low
digt = digt + 1 & 3 'Increment digit (using first two bits)
NEXT
RETURN
'~~~~~~~~~~DIGIT CONVERSION SUBROUTINE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CONVERT:
LOOKUP digit,[noparse][[/noparse]$E7,$60,$57,$75,$F0,$B5,$B7,$64,$F7,$F5],number
RETURN
END
I'm glad you got it working! Nicely done!
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!