Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:14 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : micromite - creating 16 serial ports

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 05:41am 25 Feb 2015
Copy link to clipboard 
Print this post

after recent discussions about additional serial TxD ports on the micromite i've put together an extremely simple design using a 74HC154 to switch a single TxD output between 16 different listening devices.

the '154 is a rather old component (1972 era) originally intended for memory address decoding. a 4-bit address bus would decode to 16 outputs, with the selected output further gated with two enable inputs for deglitching purposes and expansion of the decoder.

what makes the device useful today is that the 16 outputs and 2 enable inputs are all active-low. outputs Y0 to Y15 all sit at logic '1' normally, with the selected input (via A0 to A3) only going to logic '0' if E0 and E1 are both low. this makes the device compatible with the TTL serial port convention of idling at logic '1'.

we control A0 to A3 from a convenient set of (contiguous) digital output pins on the micomite, and route the COM1: TxD line into one of the enable inputs. the other enable input is not used so tied low. the HC variant of the device, the 74HC154, will operate with a Vcc between 2v and 6v (a wider range than that of the micromite), and is capable of driving 20mA loads. if 5v outputs were required, the 74HC154 could probably be supplied from a separate 5v Vcc.



the code to use this hardware is extremely simple (a single port command selecting the 1 of 16 listening devices), and will work with both the original and Mk2 micromites, along with the maximite:


setpin 2, dout
setpin 3, dout
setpin 4, dout
setpin 5, dout
OPEN "COM1:" AS #5

for i = 0 to 15
port(2,4) = i
print #5, "this is channel Y"; i
next i

CLOSE #5


note that as unselected outputs all idle at logic '1', this design is mostly NOT compatible with configuring the serial port as inverted output (option INV).

as always, the above code is totally untested, and has not been anywhere near a micromite - it may contain small syntax errors, etc. but, in principal, i believe the method should work.


cheers,
rob :-)
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 05:52am 25 Feb 2015
Copy link to clipboard 
Print this post

Untested software...will not work.
The reason is that the COM1: is buffered and you need to wait until the information is send out of the hardware uart before switching to another channel.
A solution would be to connect the TXD to an input pin and monitor that to detect when the TX is 'idle'. Or just an calculated pause.

It would actually work easier when using a bitbanged serial port, like one of the CFunctions that is in the lib. That one will 'block' until all bits are send.



Edited by TZAdvantage 2015-02-26
Microblocks. Build with logic.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 06:21am 25 Feb 2015
Copy link to clipboard 
Print this post

  TZAdvantage said   Untested software...will not work

a rather bold conjecture.

the following line of code placed after the print statement should block until the TxD buffer is empty, and seems to be the more elegant solution to a rather small oversight. a short delay may also be warranted to allow the final character in the UART itself to pass through:

do:loop until LOF(#5) = 256


cheers,
rob :-)
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9588
Posted: 01:05pm 25 Feb 2015
Copy link to clipboard 
Print this post

  robert.rozee said  
  TZAdvantage said   Untested software...will not work

a rather bold conjecture.


Note the smilies though, Rob - he was pulling your leg a little.

With nice simple code like that, there is no obvious reason I can see why that would not work without actually testing it. The added LOF line will fix the buffer issue mentioned, so your code and circuit should work fine, from what I can see - without actually testing it, mind......Edited by Grogster 2015-02-26
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025