I think I have come across a bug with the programming editor simulation, or at the very least in my understanding!
I am planning on connecting 8 sensors to a 28x2, each with its own TX and RX pins. The 'sense' subroutine is the same for each and they are polled sequentially, so I am assigning the required input and output pins via variables. Once the 'start' command has been issued the sensor will hold the RX line low for a short period and I need to know when it is released. My aim is to do this with 'do...loop while' on the RX pin. If the pin in the simulator (PE 6.0.8.10) is high before starting, it comes straight out of the loop as expected but if the pin starts off low, the programming editor does not seem to recognise the change in state of the pin and stays in the loop indefintely.
This is the snippet in question:
I tried just using the pin assignment directly and it works perfectly in the simulator:
can anyone shed any light on this?
Many thanks,
Paul
I am planning on connecting 8 sensors to a 28x2, each with its own TX and RX pins. The 'sense' subroutine is the same for each and they are polled sequentially, so I am assigning the required input and output pins via variables. Once the 'start' command has been issued the sensor will hold the RX line low for a short period and I need to know when it is released. My aim is to do this with 'do...loop while' on the RX pin. If the pin in the simulator (PE 6.0.8.10) is high before starting, it comes straight out of the loop as expected but if the pin starts off low, the programming editor does not seem to recognise the change in state of the pin and stays in the loop indefintely.
This is the snippet in question:
Code:
#picaxe 28x2
symbol sensor_id = b50
symbol sensor_rx_pin = b51
symbol sensor_tx_pin = b52
symbol PINSENSOR0RX = pinB.0
symbol PINSENSOR1RX = pinB.1
symbol PINSENSOR2RX = pinB.2
symbol PINSENSOR3RX = pinB.3
symbol PINSENSOR4RX = pinB.4
symbol PINSENSOR5RX = pinB.5
symbol PINSENSOR6RX = pinB.6
symbol PINSENSOR7Rx = pinB.7
symbol PINSENSOR0TX = C.0
symbol PINSENSOR1TX = C.1
symbol PINSENSOR2TX = C.2
symbol PINSENSOR3TX = C.3
symbol PINSENSOR4TX = C.4
symbol PINSENSOR5TX = C.5
symbol PINSENSOR6TX = C.6
symbol PINSENSOR7Tx = C.7
init:
sensor_id = 3
gosub set_sensor_pin
main:
high sensor_tx_pin
pauseus 337 ;337us low
low sensor_tx_pin
pauseus 356 ;356us high
high sensor_tx_pin
pauseus 278 ;278us low
low sensor_tx_pin
do
loop until sensor_rx_pin = 1 ;wait for sensor to release RX line
goto main
set_sensor_pin:
;assign sensor TX pin address to variable 'sensor_tx_address' and RX pin to variable 'sensor_rx_address'
lookup sensor_id,(PINSENSOR0TX,PINSENSOR1TX,PINSENSOR2TX,PINSENSOR3TX,PINSENSOR4TX,PINSENSOR5TX,PINSENSOR6TX,PINSENSOR7TX),sensor_tx_pin
lookup sensor_id,(PINSENSOR0RX,PINSENSOR1RX,PINSENSOR2RX,PINSENSOR3RX,PINSENSOR4RX,PINSENSOR5RX,PINSENSOR6RX,PINSENSOR7RX),sensor_rx_pin
return
Code:
main:
do
loop until pinB.3 = 1
goto main
Many thanks,
Paul