Using 18M2 serial input as standard input

fastgrandad

New Member
My 18M2 project requires seven digital inputs, any one of which going 'low' generates a predetirmined DAC voltage. It broadly works but the reassigned serial input (pin3, C.4) behaves oddly.
The program includes a 'disconnect' statement and the pin has a 10k pull-up resistor to +5V, as have all the other available inputs. When the program runs none of the inputs function correctly until I momentarily ground pin 3 after which it runs correctly and all seven input pins function as expected. I suspect it puts itself into some sort of loop as the DAC output is not as defined and the meter is reading an average DAC voltage, but I don't have a 'scope to look.
There are several workarounds including using the B pins as inputs instead of the C pins or move up to a 20M2 but I'm curious as to whether there is a way overcoming the issue.
 

dmaxben

Member
My 18M2 project requires seven digital inputs, any one of which going 'low' generates a predetirmined DAC voltage. It broadly works but the reassigned serial input (pin3, C.4) behaves oddly.
The program includes a 'disconnect' statement and the pin has a 10k pull-up resistor to +5V, as have all the other available inputs. When the program runs none of the inputs function correctly until I momentarily ground pin 3 after which it runs correctly and all seven input pins function as expected. I suspect it puts itself into some sort of loop as the DAC output is not as defined and the meter is reading an average DAC voltage, but I don't have a 'scope to look.
There are several workarounds including using the B pins as inputs instead of the C pins or move up to a 20M2 but I'm curious as to whether there is a way overcoming the issue.
Even before the disconnect command is acknowledged, the Picaxe still looks for a computer-download signal (high) on the serial input a couple milliseconds before it starts running the main program.

So when you have a pullup resistor on the serial input, the Picaxe thinks its getting a "program download" signal from your PC (because its seeing +5v on the serial input at powerup), and therefore it immediately goes into program-download mode instead of running the program.

You'll have to change your circuit so that the input on the serial-in idles low (pulldown resistor) and goes to +5v when you want to "actuate" the input.

Or maybe there is some other way to make a pullup resistor work when using serial-in as an input with a capacitor or something to delay the resistor from pulling up the serial-input for a couple miliseconds?? Or you could use a hex inverter chip maybe???

Ben
 

fastgrandad

New Member
Thanks Ben, that explains why it happens. I thought about using a capacitor to delay the input from going high and will give it a try but I like to understand why things are happening, rather than making a quick fix without knowing what's going on. I think the long term solution is to switch to the 'B' inputs instead as I won't need them for anything else in this project.

Paul
 

fastgrandad

New Member
I would only swap the serial port input resistors and add the capacitor and pull up resistor after the chip has been programmed so it shouldn't affect programming at all as far as I can see. We'll try it and see what happens.
 

inglewoodpete

Senior Member
I would only swap the serial port input resistors and add the capacitor and pull up resistor after the chip has been programmed so it shouldn't affect programming at all as far as I can see. We'll try it and see what happens.
You could use a removable link to the capacitor, perhaps with an alternate connection to the 22k resistor, required for programming. The link would have to be moved during programming, to isolate the capacitor. You'd have to consider that the capacitor would affect the waveform of any input signals. The rise time of an input would be slow.
 

rossko57

Senior Member
Active-Low inputs are often useful for interfacing with other kit, e.g. security systems etc.

If you had a spare _output_ pin you could use that to drive a pullup under program control - turn it on at the start of your program before monitoring for input.
 

inglewoodpete

Senior Member
Active-Low inputs are often useful for interfacing with other kit, e.g. security systems etc.

If you had a spare _output_ pin you could use that to drive a pullup under program control - turn it on at the start of your program before monitoring for input.
For most PICAXEs, if you have a spare output pin, chances are that it can be used as an input pin.
 
Top