Sending Byte by Byte to/from an old serial computer.

SolidWorksMagi

Senior Member
Hi,

I'm trying to figure out how to have a PICAXE 28x2 chip get a data stream from my PC on the serial PIN 2, then send it out via bit-banging another PIN out to an old computer byte by byte with a clocking toggle on another PIN after each byte moves through the 28x2 chip 9600 BAUD is high enough speed.

I know how to setup for serial bit-banging, but I don't really don't know how to clock the data coming in coordinated with the data clocked going out.
 

inglewoodpete

Senior Member
SerIn and SerOut are firmware-based bit-banged serial commands. These commands can be associated with almost any pin of a PICAXE.

The PICAXE firmware disables all internal (system) interrupts in order to get the critical timing required for bit-banging. As you are probably aware, timer-based operations like servo will pause during the SerIn and SerOut commands, as will background hSerIn and i2c slave operations. PWM will continue to operate unchanged, though.
 

Goeytex

Senior Member
Hi Walt,

How about a few more details ...

What is baud rate from PC?. Inverted serial or true ? How many bytes in the data stream from the PC ?

What do you mean by "...toggle on another pin after each byte..."? "Toggle" means to alternate between off and on. So that would be ON after the first byte is processed and then OFF after the second byte is processed, and so on ... Is that what you want? Or do you want it to pulse once as each byte is processed ?

Seems to me that you could use hserial background receive into a ring buffer for the incoming data and then process the data out on the fly. This should work ok as long as the data stream coming in is less than 1024 continuous bytes or is not comming in so fast that the Picaxe can't keep up.

You could also use Hserout instead of serout as this may reduce some processing overhead compared to bit-banged serial.

Bill
 
Last edited:

Buzby

Senior Member
A toggling or pulsed clock is usually associated with parallel data transfer, i.e 8 seperate data lines from the PICAXE to the device.

Is this what you mean by 'byte-by-byte' ?.
 
Last edited:

SolidWorksMagi

Senior Member
Hi,

When the "Direction Control PIN" is set 0 (GND)

I want to send data serial back and forth to the PC at 9600 BAUD 8N1 ... pretty standard. But I want to send that data 1 byte at a time while the PICAXE is also performing other tasks on each byte.

The PICAXE will receive data via either a serial port or the PINsB going high at the same time.

The idea is that it doesn't matter which port (PINsB or hserIN) gets data from an external device, but I want that data controlled at 1 byte then wait while the PICAXE does other tasks before allowing the next byte to come in and be sent to the PC.


Then when the "Direction Control PIN" is set 1 (+5)

I want the same tasks performed in the opposite direction. That is sending 1 byte at a time from the PC to the external devices at 9600 BAUD 8N1 and PINsB.
 

papaof2

Senior Member
Unless you have some "smart" communications software on the PC that the PICAXE can control, such as that software knowing that CTS (Clear To Send) active means send ONE byte, the best you're likely to do from the PICAXE is control the COM port's CTS lead - but that type of flow control must be configured on the PC for each COM port being used.
You MIGHT be able to do single byte receive control by making CTS active when the PICAXE is ready to receive a byte and then inactive as soon as the byte is received, but I'm not sure a PICAXE can recognize the end of a byte quickly enough to do that level of control before a normal PC starts sending the next byte - that may depend on the baud rate: 300 baud is much more likely to be successful than 9600.
 

inglewoodpete

Senior Member
The solution will be either hardware (CTS) as @papaof2 has described or software (handshaking), often done with XON/XOFF. Neither is too difficult but, as I mentioned in #7, you will need suitable PC software.
 
Top