Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial output from PIC - looking for resources

Status
Not open for further replies.

electronicsuk

Newbie level 4
Joined
Oct 5, 2002
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
69
vb6 serialoutput byte

I'm currently designing a computer serial port interface using PIC BASIC and the 16F84A microcontroller. I have outputs all figured out, but I would also link to be able to input to the computer from the PIC. Of course I will be using the rx pin on the serial port for this, the problem is programming the PIC. I don't want to have to poll the microcontroller every time I want to read the status of its inputs. I am trying to configure the system to automatically send data to the rx pin on the serial port whenever an input on the PIC goes high. That would be ok, but the problem is that I want to have more than one of these units connected to the port. Output is easy, just address a certain PIC and then send it the data. But with the input to the serial port, what if more than one PIC tries to send at the same time? I was thinking about making the PIC watch the rx line and check it's not busy before sending, and then toggling the pin to an output and sending the data. Even after that, it's still possible two PIC's could send at the same time if both inputs were activated at exactly the same time. So, any ideas? Any resources on the internet I could look at? Your help is much appreciated.
Best regards,
Matthew
 

You can use the newer 16F628. It has hardware rs232 and can generate an irq when someting received.

The 628 is pin compatible.
 

Thanks for the advice, i'll take a look into it. In the meantime, i'm still open to any ideas.
Many thanks,
Matthew
 

Hi ElectronicSuk (I don't think so! :wink: ),

The way you like to communicate is a bit difficult but possible.
You have to check on bit level if the tx line (from PIC) has the level of the bit you send to the PC. For example:

Set pin high
Check if output is high
If it is then continue for all bits in byte incl. start/stop for RS232.
If not then stop transmission, cause probably another PIC is transmitting and pulls the line to low. Retransmit with a small time out.

Better is to have the PC to send an addressed request to each PIC in turns. Should be OK as your data is only meant for the PC and not for the other PIC's in your system. Make a small program in Visual Basic (or so), let it send requests with an address to each PIC wait for a reply and show the data in a textbox.

I've build a similar system using 1 pin of the PIC for communication. Connected (via a resistor to 5V) and up to 240 PIC's to each other. I wrote a routine with interrupt for Rx to receive 5 bytes (incl. checksum) from a PC or master module, test the received packet and reply with the requested data to PC/Master module.

The master module is in this case another PIC programmed as data collector to check and evaluate all slave PIC's replied data and act upon as needed. The master modules have addresses from 241 to 254 and a second comms bus only intended to connect master modules to each other. So you can have 14 times 240 slaves connected .

I also did make a VB program to interrogate 240 slave PIC's and show an analogue value of their inputs in a window with 240 textboxes. So you have all devices in one overview.

This works fine for me. Hope this info will be helpful for you to decide how to proceed with your system.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top