2 Attachment(s)
Re: Reading and fixing Chinese scales
Well after Bill's suggestion of this ex POS terminal readout I went and bought one...
A couple of hours after it arrive I had it up and working (wasn't so hard, but you have to hunt Google and have an idea what you're looking for..)
A quick C# test program later and we have...
Attachment 1738
Not bad for <£8 inc postage and a few hours experimentation lol
Its bright and easily readable and the characters are 14mm high. Going to buy a couple more as they are great for PIC projects and the PCB inside is easily transferable to another housing...
Attachment 1739
Re: Reading and fixing Chinese scales
I have a Futaba display module here from another POS device, but I haven't been able to find out talk to it. I have the hardware figured, but not the serial commands.
Did you find anything odd about the serial protocol?
Bill
Re: Reading and fixing Chinese scales
Bill,
90+% of all POS displays use the Epson ESC/POS command set... 9600baud,no parity, 1 stop bit and the following command set:
ctrlH: back one position (non-destructive)
ctrlI: forward one position (non-destructive)
ctrlJ: line down
ctrlK: home
ctrlL: clear screen
ctrlM: beginning of line
ctrlX: clear line, return to beginning
ctrl?ctrlJ: line up
This PDF shows coding for other common command protocols.
Hope that helps...
Re: Reading and fixing Chinese scales
Cheers Irving, that looks promising :)
2 Attachment(s)
Re: Reading and fixing Chinese scales
Had a bit of time spare today so knocked up this bread board...
Attachment 1758
and a few tens of lines of C code later...
Attachment 1759
Many thanks to 'bogstandard' who rummaged in his box'o bits and found me a couple of cables for the scales which saved me some hassle in connecting.
This is running off a remote 1.5V supply generated using a 555 and a -ve charge pump (nit in pic), generating -6v for the RS232 into the VFD display and -1.45v for the scales and the -ve side of the comparators (uing 311 but will replace with a single quad unit) using two diodes as the reference. The PIC is a 16F877 but again will find something smaller for the final box as really dont need a 40pin device - 14 input pins (6 for the scales and 8 for a keypad), 1 UART so probably a 20pin device will do the job.
Bill/Robin, I know you guys have both done something along these lines already, how did you force the scales into fast read mode (currently I do this by hand) and, more importantly, how did you know when they got there and weren't in some 'hold' mode?
Re: Reading and fixing Chinese scales
Quote:
This is running off a remote 1.5V supply generated using a 555 and a -ve charge pump
Can't you use a spare o/p pin on the PIC instead of the 555?
Quote:
and a few tens of lines of C code later...
I s C fast enough to read the clock pulses or are you using in-line assembler ? (ISTR the guy on cnczone couldn't get it to work in C)
Quote:
Bill/Robin, I know you guys have both done something along these lines already, how did you force the scales into fast read mode (currently I do this by hand) and, more importantly, how did you know when they got there and weren't in some 'hold' mode?
If you look at the PIC code I posted on the CNCzone site, you'll see the sequence I used (I don't have it to hand ATM).
Essentially, I measure the data repeat rate from the scale to determine the current mode then apply pulses to change to the desired mode. The clk/data pulse sequence varies from scale to scale so I also test the data type to determine the type of scale.
Hold mode is a PITA because i can see no way to test the scale in in that Mode. In the end, I just used a reliable 'get back to normal' sequence then output the fast mode sequence blindly.
I have a one scale here that requires one extra pulse to get it to fast mode from hold, yet no way to determine the that this is a different type of scale from within the PIC. I will either have to program a special chip just for this scale or change the PIC code so it stores the sequence in EEPROM , that way I can change it from the PC program.
[edit]
Here you go:
Code:
;Zero vernier display
Zero movf rxbuff+1,w
andlw 0xDF
xorwf IDbyte,w ;test correct axis
btfss status,z
return
call zeronorm
btfss Mode,Fast ;if it was in fast mode then setfast
return
goto setFast
;set zero normal mode
ZeroNorm call measure ;measure checks the clock to determine fast/slow mode
btfss Mode,Fflg
goto tstslow
pdlp call PlsData ;pulse data until slow
call measure
btfsc Mode,Fflg ;test slow
goto pdlp
call PlsClk ;pulse clk (zero switch)
return
;measure the vernier reading speed (300mS slow,20mS fast)
measure bcf CMCON,CIS ;switch comp to clk input
call synlp ;wait for clock low >1mS
bcf Mode,Fflg
;if clock occurs within ~25mS then Fast flag will be set
movlw 25
movwf vdata ;borrow vdata as counter
m2lp btfsc CMCON,COUT
bsf Mode,Fflg ;
decfsz vdata+3,f
goto m2lp
decfsz vdata,f
goto m2lp
return
Tstslow call PlsClk ;pulse clk
call measure
btfsc Mode,Fflg ;test slow
goto pdlp ;if fast, pulse data until slow
return ;normal zero
Re: Reading and fixing Chinese scales
Its easily fast enough in C whan you're running a 20Mhz clock - this scale is running at 74KHz clock rate or 13.5uS.. the actual C routine to sample the clock, determine the falling edge, read the data line and shift it into a 32bit register is 49 assembler instructions (7 lines of C) which takes 9.8uS. It may be that on another scale it will need optimising... although this compiler is pretty good but being C it tends to use temporary variables in RAM (mainly becuase I haven't yet worked out how to force it to use registers as variables)
Code:
//now in lead up to second data burst
unsigned char count=24;
long data = 0;
while(count>0)
{
data >>= 1; //prepare for next bit
while(CK==1); //wait for clock to go low
if(DT==1) //sample data
data |= 0x00800000;
while(CK==0); //wait for clock to go hi
count--;
}
//do stuff with data...
doubt I could read three scales on one PIC tho in C and I want to do that so the real one will use a 20pin device 18F1220 at 40Mhz...