Exact match. Not showing close matches.
PICList
Thread
'[SX] is it possible to change SX/B 8 bit Commands '
2007\02\10@153711
by
Capt. Quirkn/a
|
|
I was trying to use Ken Gracy's .bs2 mill example into SX/B code and ran into a problem with "LOOKDOWN" requiring only 8 bit variables and so I was thinking maybe by combining RB & RC ports to "RBC".
Would that allow 16 bit variables then? and would that work across the board for other commands that require a 0 - 255, 8 bit variable.
Thanks
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
I know you can specify the higher byte or lower byte of a word variable by doing something like
If you declared the variable wordvariable WORD and then did this
RB = word_LSB this would output the LOWER BYTE of the word to the port RB and
RC = word_MSB this would output the UPPER BYTE of the word to the port RC this feature is not documented well in the help sections.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171298
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\02\10@170334 by Capt. Quirkn/a
|
|
"Lookdown" requires a Byte variable or a number value between 0 - 255 and so do a lot of other commands like RCTIME, PULSOUT, etc. If you need a variable like 10,000 and declare it as a word, SX/B returns an error declaring a "expected Byte varible".
With some of the Commands you can use multipliers to prevent this, but others you can't. Thats why I thought RBC may fix that.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171306
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
There may be other ways to do what you want without passing a word variable to a command that can only use a byte.
Got a link to your code?
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171345
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\02\10@224220 by Capt. Quirkn/a
|
|
Here you go
' =========================================================================
'
' File...... Mill_Speedo.BS2
' Purpose... Wabeco CC-1210 Milling RPM Measurement
' Author.... K. Gracy?
' E-mail....
' Started...04 JUN 2004
' Modified by..Bill Mazzacane
' Updated... 10 FEB 2007
'
' =========================================================================
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'In the process of changing it over to SX/B
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE SX28, OSCHS2, TURBO, STACKX, OPTIONX
FREQ 20_000_000
ID "SXB 1.50"
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
E PIN RB.1 ' LCD Enable
RW PIN RB.2 ' Read/Write\
RS PIN RB.3 ' Reg Select (1 = char)
LcdDirs VAR RB 'DIRB ' dirs for I/O redirection
LcdBus VAR RB 'OUTB
SpeedIn PIN RC.0 ' Melexis 90217 output
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
'#DEFINE Lcd = 1 ' set to 0 for VFD
'#DEFINE BarGraph = 1 ' set to 0 for no graph
LcdCls CON $01 ' clear the LCD
LcdHome CON $02 ' move cursor home
LcdCrsrL CON $10 ' move cursor left
LcdCrsrR CON $14 ' move cursor right
LcdDispL CON $18 ' shift chars left
LcdDispR CON $1C ' shift chars right
LcdDDRam CON $80 ' Display Data RAM control
LcdCGRam CON $40 ' Character Generator RAM
LcdLine1 CON $80 ' DDRAM address of line 1
LcdLine2 CON $C0 ' DDRAM address of line 2
A CON 10_000
B CON 1_000
D CON 100
R CON 10
F CON 0
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
char VAR Byte ' for LCD
addr VAR Word ' ee pointer (for DATA)
pulses VAR Word ' input pulses from motor
rpm VAR Word ' motor RPM
percent VAR Byte ' % of max speed (7500)
fldPos VAR Byte ' field position
value VAR WORD ' value to print
width VAR Byte ' width of print field
pad VAR Byte ' spaces for rj printing
idx VAR Byte ' loop counter
cols VAR Byte ' total graph colums
blox VAR Byte ' whole blocks for graph
' -------------------------------------------------------------------------
INTERRUPT
' -------------------------------------------------------------------------
ISR_Start:
' ISR code here
ISR_Exit:
RETURNINT ' {cycles}
' =========================================================================
PROGRAM Start
' =========================================================================
' -----[ EEPROM Data ]-----------------------------------------------------
Banner1:
DATA " KEN GRACEY ", 0
Banner2:
DATA "MILL SPEEDOMETER", 0
DefaultL1:
DATA " 0 RPM 0 %", 0
'#IF Lcd #THEN
'CC0 DATA $10, $10, $10, $10, $10, $10, $10, $00
'CC1 DATA $18, $18, $18, $18, $18, $18, $18, $00
'CC2 DATA $1C, $1C, $1C, $1C, $1C, $1C, $1C, $00
'CC3 DATA $1E, $1E, $1E, $1E, $1E, $1E, $1E, $00
'CC4 DATA $1F, $1F, $1F, $1F, $1F, $1F, $1F, $00
'#ENDIF
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
Show_RPM SUB
Show_Percent SUB
LCD_Put_String SUB
LCD_Put_RJ_Value SUB
LCD_Command SUB
LCD_Write SUB
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
TRIS_B = %11111101 ' setup pins for LCD
LOW RW
LCD_Init:
PAUSE 500 ' let the LCD settle
LcdBus = %0011 ' 8-bit mode
PULSOUT E, 1
PAUSE 5
PULSOUT E, 1
PAUSE 0
PULSOUT E, 1
PAUSE 0
LcdBus = %0010 ' 4-bit mode
PULSOUT E, 1
char = %00101000 ' multi-line mode
GOSUB LCD_Command
char = %00001100 ' disp on, no crsr, no blink
GOSUB LCD_Command
char = %00000110 ' inc crsr, no disp shift
GOSUB LCD_Command
'NOT REQUIRED
'DL_Characters:
'#IF Lcd #THEN
'char = LcdCGRam ' point to CG RAM
'GOSUB LCD_Command ' prepare to write CG data
' FOR idx = CC0 TO (CC4 + 7) ' build 5 custom chars
' READ idx, char ' get byte from EEPROM
' GOSUB LCD_Write ' put into LCD CG RAM
'NEXT
'#ENDIF
Banner:
char = LcdCls
GOSUB LCD_Command
DO
READ Banner1 + addr, char
addr = addr + 1
IF char = 0 THEN EXIT
GOSUB LCD_Write
LOOP
GOSUB LCD_Put_String
char = LcdLine2
GOSUB LCD_Command
DO
READ Banner2 + addr, char
addr = addr + 1
IF char = 0 THEN EXIT
GOSUB LCD_Write
LOOP
GOSUB LCD_Put_String
PAUSE 3000
char = LcdCls
GOSUB LCD_Command
Main:
addr = DefaultL1
GOSUB LCD_Put_String
COUNT SpeedIn, 1000, Pulses
RPM = Pulses * 60
GOSUB Show_RPM
'percent = rpm / 75
GOSUB Show_Percent
GOTO Main
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
Show_RPM:
char = LcdLine1
GOSUB LCD_Command
width = 4
value = rpm
GOSUB LCD_Put_RJ_Value
RETURN
Show_Percent:
char = LcdLine1 + 11
GOSUB LCD_Command
width = 3
value = percent
GOSUB LCD_Put_RJ_Value
' NOT REQUIRED
'#IF BarGraph #THEN
'char = LcdLine2 ' position cursor
'GOSUB LCD_Command
'cols = percent */ 205 ' x 0.8 (100% = 80 pixels)
'blox = cols / 5 ' calculate whole blocks
'IF (blox > 0) THEN
'char = 4
'FOR idx = 1 TO blox.
' GOSUB LCD_Write
' NEXT
'ENDIF
' LOOKUP (cols // 5), [" ", 0, 1, 2, 3], char ' partial block
'GOSUB LCD_Write
'char = " "
' FOR idx = 0 TO (16 - blox) ' clear end of graph display
' GOSUB LCD_Write
' NEXT
' #ENDIF
'RETURN
' Writes stored (in DATA statement) zero-terminated string to LCD
' -- position LCD cursor
' -- point to 0-terminated string (first location in 'addr')
LCD_Put_String:
DO
READ addr, char
addr = addr + 1
IF char = 0 THEN EXIT
GOSUB LCD_Write
LOOP
RETURN
' Write right-justified value at cursor position
' -- move cursor to left-most position of field
' -- put field width if 'width' (1 to 5)
' -- put value in 'value'
'------------------------------------------------------------------------
'EXAMPLE FROM HELP SECTION
' idx = 3
'LOOKUP idx, $00, $01, $02, $04, $08, $10, $20, $40, $80, LEDs
'---------------------------------------------------------------------------------
LCD_Put_RJ_Value:
LOOKDOWN value, >=[10000, 1000, 100, 10, 0], pad 'Gives error #11 "Byte Variable Expected"
pad = pad - (5 - width) 'All 7 errors are within this routine
IF (pad > 0) THEN 'I was planing on checking this version with
char = " " 'SX-Key Debug and compare results with the actual
FOR idx = 1 TO pad 'BS2 program
GOSUB LCD_Write
NEXT
ENDIF
FOR idx = (width - pad - 1) TO 0
char = value DIG idx + "0"
GOSUB LCD_Write
NEXT
RETURN
' Send command to LCD
' -- put command byte in 'char'
LCD_Command: ' write command to LCD
LOW RS
' Write character to current cursor position
' -- but byte to write in 'char'
LCD_Write:
LcdBus = char ' output high nibble
PULSOUT E, 3
SWAP char ' strobe the Enable line
LcdBus = char ' output low nibble
PULSOUT E, 3
HIGH RS ' return to character mode
RETURN
' =========================================================================
' User Data
' =========================================================================
Pgm_ID:
DATA "SX/B 1.50 Template", 0
Thanks
Bill
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171357
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
Bill,
The way I did this for my HC4LED displays was to put the digits in an array. Then at the end figure out how many leading digits to blank.
If you don't need to blank leading digits, then you can just output them.
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171388
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\02\12@031846 by Capt. Quirkn/a
|
|
Bean,
Me and array's don't get along, Would you mind going one step further and show me how you would declare that code
Thanks
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171284#m171626
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
Try this...
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
digits VAR Byte (5) ' holds digits for display
'---------------------------------------------------------------------------------
LCD_Put_RJ_Value:
' Init digits to all zeros
PUT digits, "00000"
' Convert value to ascii digits
DO WHILE value >= 10000
INC digits(0)
value = value - 10000
LOOP
DO WHILE value >= 1000
INC digits(1)
value = value - 1000
LOOP
DO WHILE value >= 100
INC digits(2)
value = value - 100
LOOP
DO WHILE value >= 10
INC digits(3)
value = value - 10
LOOP
digits(4) = digits(4) + value_LSB
' Blank leading zeros
idx = 0
DO WHILE idx < 4
IF digits(idx) = "0" THEN ' IF digit is Zero...
digits(idx) = " " ' make it Blank
ELSE
idx = 4 ' Set counter to done value
ENDIF
INC idx
LOOP
' Send digits to LCD
FOR idx = 0 TO 4
char = digits(idx)
GOSUB LCD_Write
NEXT
RETURN
More... (looser matching)
- Last day of these posts
- In 2007
, 2008 only
- Today
- New search...