PDA

View Full Version : PIC communication



LexManos
- 15th November 2009, 09:23
Alright i'll give you guys the qucik and dirty of what my friends and I are doing, and what we need to figure out.
And if this is a bad post feel free to let me know and i'll get rid of it if i can.

We are trying to design a lazer tag system.
We have seperated it into two components which will do there own things.
The Vest: Will always wait for incoming IR data
The Gun: Will only shoot IR data when trigger is pressed.

What we need to figure out is how to communicate between the two, say we transmit the 'full ammo' code to the vest, we need to transmit from the vest to the gun, that it should fill it's ammo.

Thing is, all we can think of are PWM data transfer between the two chips, BUT, there is no way for us to figure out if the gun should be listening for data or not...
This is a vary stupid problem but i'm bad at designing this thing and my friends are no help.
I'm also bad at describing it, so if anyone is willing to spend some time with me, I can describe it better.

mackrackit
- 15th November 2009, 09:54
http://www.picbasic.co.uk/forum/showpost.php?p=18927&postcount=4

LexManos
- 15th November 2009, 11:04
Ya, thats what started us off, but there are a few problems:
1) They are no longer in busniess so we can't get parts
2) There 'full source code' is actually not even 1/2 of the code needed.
3) It does not support any of the features we want
4) Is a single chip system meaning the gun is the vest, giving issues of you being invincible while firing and **** like that.

This brings be back to my main question, how can we communicate between 2 micro controlers? When one is a dedicated listener (for incoming IR) and the other is a transmitter.
Note, we will be having 2 wires going between the chips we can use, (we are using 3 but one is a simple sanity wire)

mackrackit
- 15th November 2009, 12:53
Oh, I did not check if the link was still good... Sorry.

For communicating between two MCUs with wires is not to difficult. This page has several examples, look at ser2mod.bas and usart.bas for the basics.
http://melabs.com/resources/samples.htm

I think for you project I would go with USART because you may want tohave it working with an interrupt.

To help with the USART calcs and other stuff this is a very handy tool and the link is good.
http://www.picbasic.co.uk/forum/showthread.php?t=4994

Now for a really slick way of interrupting.
http://www.picbasic.co.uk/forum/showthread.php?t=3251

Let us know if that is any help...

LexManos
- 19th November 2009, 15:30
Thanks for the links, I've read over them and figured a few things out.
What i'm stuck on now is the math to try and figure out how I can make a timer that ticks every 1 or 10 microseconds. To encode the IR data I need to step in 600 microsecond intervals. I figure if I write an interrupt timer, that does nothing but increase a tick count (c = c + 1) I can check in my main loop of I should stop/start the IR data: If (Count = 60) Then Low IRPin
should work if Count is incremented every 10 microseconds :/

I found an Elapsed time Demo (http://www.picbasic.co.uk/forum/showthread.php?t=190) but I need something that is at least 10x more accurate then that :( [ideally 50x-100x more accurate]

mackrackit
- 19th November 2009, 19:46
Do a forum search for mister e multicalc. Most of us cheat anymore and us it :)