Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:08 16 May 2024 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 : CFunction - SerialRx

Author Message
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 01:46pm 10 Jun 2015
Copy link to clipboard 
Print this post

Had a quick question for you guys. The CFunction - SerialRx function will only return characters received while the function is waiting for input. How would you get it to act like a normal serial input with an interrupt? Do you setup a settick timer and check every 1000 seconds?
MkII 44pin - v5.0

ColorMax 2 - v4.5
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 09:45pm 10 Jun 2015
Copy link to clipboard 
Print this post

No, sorry. This is a limitation of the SerialRx function and it would be impracticable to try and implement a full interrupt driven input queue inside a CFunction.

You will just have to use COM1 or COM2 for that or use a 28-pin chip as a I2C slave with two extra COM ports.

Geoff
Geoff Graham - http://geoffg.net
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 10:16pm 10 Jun 2015
Copy link to clipboard 
Print this post

I have a MM acting as two additional serial ports, slaved to a Maximite on I2C.
Works well, however, you still need to know when to start the I2C comms.

In my case, I used a couple of handshaking lines from the slave MM back to the Maximite master, which were used with normal interrupts to let the Maximite know when the slave wanted to send it data from the com port.

Seems complicated, but it actually is easier then you think, with a little bit of code.

Another option would be to use a PICAXE chained to a MM chip on I2C, as the PICAXE has the option to use serial on just about any pin for both input and output serial streams. This would be how I would do it, if I needed more then a couple of serial ports. The trade-off here is that the PICAXE, although it can have serial in and out on several pins, has no serial port buffering and limited serial port speed, whereas the MM has buffering for both it's ports and very good speed - especially on COM1, which makes it a winner as far as I am concerned.
Smoke makes things work. When the smoke gets out, it stops!
 
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 03:11pm 14 Jun 2015
Copy link to clipboard 
Print this post

That was going to be my second question, if the I2C slave still works with Com ports. Perfect, gives me lots of options to play around with on paper, before I start breadboarding my system.

My troubles is the baud rate for the two devices is 57600, which only gives me Com1. With the 2 devices (A & B) talking back and forth, I want to sneak in the middle and submit my own serial data to deviceA the odd time. I'm thinking instead of reading DeviceB, and passing the data to DeviceA, I'll just use a relay or some type of IC switching chip. Default state is letting A and B talk back and forth. When I want to send my code, I'll turn on the switch, send my code, and turn off the switch.


MkII 44pin - v5.0

ColorMax 2 - v4.5
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 04:28pm 14 Jun 2015
Copy link to clipboard 
Print this post

My guess would also be that there must be some I2C serial-port chips, that will have multiple hardware UART's and on-board buffering - I will have a look around, and post back if I find anything. An I2C UART chip may well be just what you need, as you need a couple of higher-speed COM ports, assuming such a device exists(I would be surprised if not).
Smoke makes things work. When the smoke gets out, it stops!
 
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 05:04pm 14 Jun 2015
Copy link to clipboard 
Print this post

Been doing some searching tonight, looks like Maxim might have something. I wish I still had my college email address to get free samples.

Single UART can be switched to 4 different transceivers.
Max399 - CMOS analog multiplexer

MkII 44pin - v5.0

ColorMax 2 - v4.5
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 05:19pm 14 Jun 2015
Copy link to clipboard 
Print this post

Yeah, that thing looks even better, as you just use COM1 on the MM, feed it into this thing, and have two control lines back from it, to the MM to select the device you want to talk to.

I'm gonna read the datasheet for this thing myself now, as this is an interesting device, and as I do lots of serial stuff, I am always running out of serial ports!
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 05:27pm 14 Jun 2015
Copy link to clipboard 
Print this post

  MolsonB said  I'll just use a relay or some type of IC switching chip. Default state is letting A and B talk back and forth. When I want to send my code, I'll turn on the switch, send my code, and turn off the switch.


That is also a very easy and cheap way to do it with some DPDT relays from eBay.
I did exactly that in one of my boards - switching COM1 between a paging transmitter, and a network module. It works beautifully, and the relay has the added bonus of a much lower on resistance then any of the mux chips I have looked at.

So long as only one device has to talk at any one time, then you can setup one relay for every device. External devices come in on relay NO contacts, and all the relay common's are paralleled up and connected to the COM port on the MM. When the MM wants to talk to a specific unit, it just pulls in that relay, does it's talking, and drops the relay back out again. This actually works extremely well, and is simple, so something ELSE to think about....
Smoke makes things work. When the smoke gets out, it stops!
 
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 05:56pm 14 Jun 2015
Copy link to clipboard 
Print this post

I'm not sure why it took so long tonight for me to find that multiplex chip. I've been on the maxim site lots with the good old Max232.

I have a relay sitting infront of me, but it's made for a circuit board and not breadboard. Was to lazy to solder wire onto it so I came on here instead. I really only need to control the TX line, so 1 relay with NO/NC would work just as easy (and cheap). Great thing is, without power, the system would run as desire with A and B talking.

Do you have any favorite DIP relay?



MkII 44pin - v5.0

ColorMax 2 - v4.5
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 07:53pm 14 Jun 2015
Copy link to clipboard 
Print this post

I like the HC19F series of DIL PCB relay, like these ones:

DPDT DIL RELAY, 5v COIL

Four bucks for five relays, and free shipping.

With 5v coil, you can drive them from a 5v rail. You can also get 12v coil ones if you like, but the 5v ones allow you to use the main 5v rail that is normally floating about most projects, to drive the relay.

In your case, you would only use one side of the relay(one pole).
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


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

© JAQ Software 2024