I'm building a tide level data logger. I've finished the electronics hardware. It can measure a tidal range of 4 metres with a resolution of 1 mm.
The output is a 12 bits of parallel data.
I need to send this over a wired serial conection. Data rate can be slow since it only has to be read once every few minutes.
I'm trying to use the UART in a 16F627. The parallel data is input on Port A for the LS 8 bits. The most significant 4 bits are on RB 4,5,6,7
I can get the UART to send fixed constants or text (Hello World) and I can read it over the serial link. However, I just can't seem to read the data from the input pins. I always seem to end up just sending zero whatever data I put on the inputs. It's a long time since I did any of this stuff, I think I'm missing something obvious, but as an older person, the obvious gets harder and harder to spot.
Any help would be appreciated.
The output is a 12 bits of parallel data.
I need to send this over a wired serial conection. Data rate can be slow since it only has to be read once every few minutes.
I'm trying to use the UART in a 16F627. The parallel data is input on Port A for the LS 8 bits. The most significant 4 bits are on RB 4,5,6,7
I can get the UART to send fixed constants or text (Hello World) and I can read it over the serial link. However, I just can't seem to read the data from the input pins. I always seem to end up just sending zero whatever data I put on the inputs. It's a long time since I did any of this stuff, I think I'm missing something obvious, but as an older person, the obvious gets harder and harder to spot.
Any help would be appreciated.
Code:
'12 bit Parallel to Serial by Derek Hodge
'11 Oct 2013
'Device 18-pin 16F627A
'Inputs RA0 - RA7 , RB4, RB5, RB6, RB7
'serial out TX Pin 8
Define CONFIG = 0x3f18
Define CLOCK_FREQUENCY = 4
AllDigital
Hseropen 4800
TRISA = 0xff 'Set Port A as input. Have also tried this using CONFIGPIN but same result
TRISB = 0xf0 'Set most significant 4 bits of PORT B as input
Dim ls8 As Byte 'LS 8 bits
Dim ms4 As Byte 'MS 4 bits
loop:
PORTA = ls8
PORTB = ms4
Low ms4.0 'Make sure LS bits are 0
Low ms4.1
Low ms4.2
Low ms4.3
ms4 = ShiftRight(ms4, 4) 'Move the data bits from most significant positions to LS positions
Hserout ls8, ","
Hserout ms4, CrLf
WaitMs 500
Goto loop