PDA

View Full Version : Making the Lab X1 communicate with the Lab X2



MatthewM
- 19th June 2008, 16:47
Hi,

I am very new to the world of programming, and am having trouble working with interrupts, specifically with this project I am working on.

The project is getting the Lab X1 board to communicate with the Lab X2 board using only one wire (as I need to then apply what I learn to a different project where I only have one I/O pin to use) it is only a one way communication. What I want to do is;

Upon pressing switch one or two on the Lab X1, either LED 2 or 3 will light up on the Lab X2 as long as the switches are pressed.

As far as I can tell, I need the have a interrupt on the receiving chip to handle which light to turn on, with the interrupt being initiated externally, unfortunately I am not entirely sure how to do this. I also have very little idea on how to do the serial communication between the two chips...I have spent hours in RTFM sessions, with little to show for it.

I am wondering if anyone here could point me in the right direction with some stupid simple guides on external interrupts, or possibly show me some sample code and explain how it works...For some reason, all the books I have read out of don't make much sense to me when it comes to these things.

Thank you,
Matt

skimask
- 19th June 2008, 17:09
I am very new to the world of programming, and am having trouble working with interrupts, specifically with this project I am working on.
The big question is...what else have you done so far that is remotely related to a project like this?


Upon pressing switch one or two on the Lab X1, either LED 2 or 3 will light up on the Lab X2 as long as the switches are pressed.
Then forget the interrupts and just 'make it work' without the interrupts, poll for the 'commands', wait for them, act on them, and keep going.
When that all works, THEN add the interrupts.

And when you do get around to adding interrupts, forget about having 2 PICs talk to each other with an interrupt based system. Make one PIC respond to a button press THRU an interrupt rather than just polling. Then make it send out a 'command' when interrupted by a button press.
Once you figure that out, it's a simple matter of getting a serial input to trigger an interrupt and do what you want.

MatthewM
- 19th June 2008, 18:23
I say I am very new to programming because I have about three weeks into learning it, I was offered a job from my father to write the programs he uses in various applications, as such, I am trying to learn it as fast as humanly possible. I have done several sample projects pertaining to both interrupts and serial communication that where in the various books I have collected to learn PicBasic Pro, it's just serial communication and interrupts don't make much sense to me, from the information I have...Even after reviewing it several times. I think it's just a lack of understanding the concepts behind the two, which is why I am looking for more resources on them.

Right now, whats hanging me up more than anything is the serial communications...I have had a hard time finding sample programs of two PICs interfaced with one another.

Ideally I would like to find two sample codes for making Lab X boards talk to one another.

Thank you,
Matt

skimask
- 19th June 2008, 18:25
Right now, whats hanging me up more than anything is the serial communications...I have had a hard time finding sample programs of two PICs interfaced with one another.
A little bit of searching on these forums, right here, the PicBasicPro forums, the little search button at the top of the screen, blue background, white lettering, with a little downward facing arrow next to it, will get you a long way.

You don't need an example of "2 Lab X boards talking to each" specifically, you only need an example where a PIC, any PIC, talks to another PIC, any PIC, thru some method.

MatthewM
- 19th June 2008, 18:32
Thank you for the advice,

Yes, I realize I don't need that specific of a program, it would just be ideal, since I could then easily implement it on my desk, and see the end results of how it worked.

I am also searching through the forums, I was just curious if anyone knew of some off site resources as well, since searching Google has yielded me little or happened to know of something offhand that I may have missed in my searches, also, I figured I would put my situation out there in case there was a simple answer to it that I was just missing (I can't count how many times I have been hung up on something for hours, only to find the simplest, most obvious solution).

Matt

skimask
- 19th June 2008, 18:44
Yes, I realize I don't need that specific of a program, it would just be ideal, since I could then easily implement it on my desk, and see the end results of how it worked.
I am also searching through the forums, I was just curious if anyone knew of some off site resources as well.................
Matt

That's what I'm saying...there is a complete example of 2 PIC communication here...on this site...done by one of the most advanced members of this forum (no, not myself, obviously). I don't know what the thread is called, can't remember the title, but it's complete. And most likely you'll have to change it to match your PIC, your hardware, your needs.

MatthewM
- 19th June 2008, 18:46
Oh, okay, thank you. I will attempt to find it immediately.

Matt

skimask
- 19th June 2008, 18:47
Oh, okay, thank you. I will attempt to find it immediately.

Matt

http://www.picbasic.co.uk/forum/showthread.php?t=573

Found it...right there in the 'Code Examples' section....half a page down...right there...

MatthewM
- 19th June 2008, 19:12
Are you referring to the program she wrote for PC to PIC? Or is there another program in this thread for PIC2PIC?

Thanks,
Matt

skimask
- 19th June 2008, 19:31
Are you referring to the program she wrote for PC to PIC? Or is there another program in this thread for PIC2PIC?
Yep, you're right...you want PIC-PIC not PC-PIC (missing an eye in there somewhere)
Try this:
http://www.picbasic.co.uk/forum/showthread.php?t=4130&highlight=bidirectional
Then head over to www.rentron.com and snoop around there for awhile.

MatthewM
- 19th June 2008, 20:38
Sweet, thanks for all the help...I am under quite a bit of pressure to make some progress, any any help is wonderful.

Matt

skimask
- 19th June 2008, 20:50
Let me guess...
It's a college/higher educational assignment of some sort...

MatthewM
- 19th June 2008, 22:26
Actually, no, as I said, it's just something I need to figure out how to do for a code I need to write that will go into one of the micro controllers that my father uses in the controls he sells.

I am not even in college, I just finished my junior year of High School, I needed a job, so this is what I got...But, I can't get paid until I can do something of value, so I need to learn to be proficient with PicBasic Pro as soon as I can. Because of this, I am under a bit of pressure to learn quickly.

Matt