PDA

View Full Version : How to make your own PIC network



mister_e
- 5th February 2005, 01:56
Hi everybody,

Since a few time, i see some request or project that involve some kind of PIC network.

It seems to be still obscure for some. So i decide to give a hand on that.

The package include code and schematic for MASTER and SLAVE. I choose the PIC16F628. To do the serial communication, i choose to use SEROUT and SERIN2.

WHY? The reason is simple. Many question on those statement are still asked AND some user will use some PIC without any internal USART. Like the Ralph's favourite PIC16F84. Sorry Ralph ;)

Yep, it's only a really simple example but, i think, i hope, it will be handy for somebody on this earth.

Have fun!

Demon
- 5th February 2005, 03:12
Just the sample I was looking for.

Merci!

Robert
:)

Demon
- 5th February 2005, 03:30
Is there a maximum to how many slaves we can address?

I've been reading so much in the last few days, I know I read it somewhere but I can't remember which forum, thread, tutorial or document...

Robert
:)

mister_e
- 5th February 2005, 03:40
If you remove the dipswitch stuff and you're using a WORD sized variable instead, it "should" work... so a max of 65536 Slaves wich is not so bad.

In this case you'll have to send this variable in two bytes

MASTER:
----------
SlaveSelect var word

serout serialoutput, t2400, ["SLAVE",SlaveSelect.lowbyte,SlaveSelect.highbyte,DATATOSE ND]

SLAVES:
----------
SlaveSelect var WORD

serin2 serialinput,t2400,[WAIT ("SLAVE",slaveselect.lowbyte,slaveselect.highbyte),datatod isplay]



--------------
Should work

BtW Everything is in the header... IMO there's no limit...

Demon
- 5th February 2005, 05:04
Get to work you bum! You're late!

Thanks Mr. E, excellent news on the lack of slave limit.

Robert
:D

NavMicroSystems
- 6th February 2005, 01:04
Hi Steve,

great initiative!

I think this is something worth to be discussed.

sakthi
- 27th December 2006, 13:41
hi all

i m also doing the same pic to pic comm via spi.i m using 16f877a.
i have written the code in C.soma junk value is displayed n the receiver side lcd.but my opinion is there s no communication between two pic,if i switch off the transmitter pic then also the lcd s displaying the same junk value.

void transmit(char *str)
{
int i;
char dum;
SSPBUF=0;
for(i=0;i<6;i++)
{
SSPBUF=str[i];
//delay();
dum=SSPBUF;
delay();
}
}
void init_spi()
{
STATUS.f6=0;
STATUS.f5=1;
TRISC=0;
TRISB.f1=0;
TRISE.f2=0;
STATUS.f5=0;
PORTC=0;
TRISC.f5=0;
TRISC.f3=0;
TRISC.f4=1;
STATUS.f5=1;
SSPSTAT.f7=0;
SSPSTAT.f6=0;
STATUS.f5=0;
//SSPCON&=0xf0;
SSPCON.f5=1;
SSPCON.f4=0 ;
SSPCON.f0=0 ;
SSPCON.f1=0 ;
SSPCON.f2=0 ;
SSPCON.f3=0 ;
}
void main()
{
init_spi();
transmit("sakthi");
}

the above code s for transmitting side.i have used two seperate pic board.



void receive()
{
int i;
char rx[10];
STATUS.f5=0;
STATUS.f6=0;
PIR1.f3=0;
SSPBUF=0;
for(i=0;i<6;i++)
{
while(SSPSTAT.f0==0)
{}
while(PIR1.f3==0)
{}
rx[i]=SSPBUF;
//delay();
toggle();
SSPBUF=0;
SSPSTAT.f0=0;
PIR1.f3=0;

}
}
void init_spi()
{
STATUS.f6=0;
STATUS.f5=1;
TRISC.f4=1;
TRISC.f5=0;
TRISC.f3=1;
STATUS.f5=1;
TRISA.f5=0;
SSPSTAT.f7=0;
SSPSTAT.f6=1;
STATUS.f5=0;
SSPCON.f5=1;
SSPCON.f4=1 ;
SSPCON.f0=0 ;
SSPCON.f1=1 ;
SSPCON.f2=0 ;
SSPCON.f3=0 ;
}
void main()
{
STATUS.f5=1;
STATUs.f6=0;
SSPCON.f5=0;
init_spi();
receive();
init_lcd();
display(rx);
}


the above code s for reception .plz any one help me to solve the problem.i have the doubt in the register enabling.plzzzzzzzzzzzzz help me

keithdoxey
- 27th December 2006, 14:49
i have written the code in C.
plz any one help me to solve the problem.
plzzzzzzzzzzzzz help me

.... I just dont get it. Maybe its my crappy eyesight but I see the name of this forum as

MELabs PICBASIC Forum

I am obviously overdue for a sight test as others see it as

MELabs PICBASIC Forum

skimask
- 27th December 2006, 14:57
.... I just dont get it. Maybe its my crappy eyesight but I see the name of this forum as

MELabs PICBASIC Forum

I am obviously overdue for a sight test as others see it as

MELabs PICBASIC Forum



Ya, no kidding. Have you seen this guy's other posts around here?

Refer to Post #6 in http://www.picbasic.co.uk/forum/showthread.php?t=2570

It's always the same thing, they always end with... CANYOU HELP ME PLZZZZZZZZZZZZZZZZZZZZZZZ... or maybe PLZ...whatever...

cosmomen
- 8th January 2007, 16:06
Hi there!

I'm working on a project where I need to interconnect a few PIC's
I need bi-directional communication with a master PIC. the best solution would be the onewire but i vould accept i2C or any other good idea. Could please somebudy help me with a short example? I have no problems to communicate with I2C or OW devices but I don't know how to create a slave unit.

Many thanks in advance

mister_e
- 8th January 2007, 18:39
You could still use some PIC with the MSSP mosule built in and work around this... it's not going to be really easy but doable.

Simple RS232 comm with a busy line is still the easiest way.

sakthi
- 10th January 2007, 14:48
hi all

i need a help. i m using til81(phototransistor) in the receiver side,and an led r IRled or LED55 n the transmitter side.if the light intensity frm the transmitter s varied the output of the til81 should vary.but for me,i m using ordinary led,but the output s not varying if i provide any obstacle.plz any one help me to get the datasheet for til81plz help me

Sakthi

skimask
- 10th January 2007, 15:26
hi all

i need a help. i m using til81(phototransistor) in the receiver side,and an led r IRled or LED55 n the transmitter side.if the light intensity frm the transmitter s varied the output of the til81 should vary.but for me,i m using ordinary led,but the output s not varying if i provide any obstacle.plz any one help me to get the datasheet for til81plz help me

Sakthi

And you want to program it in C right?

keithdoxey
- 10th January 2007, 15:39
And you want to program it in C right?
Not sure why but I have stange feeling of Deja Vu

skimask
- 10th January 2007, 15:41
Not sure why but I have stange feeling of Deja Vu

In these cases, I get 'Vu Ja De'... (Voo Zya Day, not Day Zya Voo)
ya know, that feeling that you've never been there in a situation nothing like that before :)

mister_e
- 10th January 2007, 18:15
Not sure of this 'Vu Ja De' expression... more than likely it's 'Déja Vue'. It's a french expression wich mean 'Already seen' not much.

skimask
- 10th January 2007, 19:26
Not sure of this 'Vu Ja De' expression... more than likely it's 'Déja Vue'. It's a french expression wich mean 'Already seen' not much.

In PBP...

Vu Ja De = ~ ( Deja Vue )

Acetronics2
- 11th January 2007, 16:49
hi all

the datasheet for til81plz help me

Sakthi

here : http://www.datasheetarchive.com/datasheet.php?article=3723931

Alain

PS ... think to remove dust from that chip, I've some here dating from the 70's.
May be your range problems come from that ???

programmer07
- 27th February 2007, 21:05
dear mister_e;

i see that you dont use "rx" or "tx" pin for receive?

how can i make your master for dmx 512 decode and your slave to receive for 512adress i know i have tome add 9 dipsw on it and i will use it only for 3 leds no more 3 chanel is ok for me can you help?

slave for 512dmx adres receive and 3 output in 250000baudrate ?

mister_e
- 27th February 2007, 23:51
What you need to do is not as this simple for a first school project.

DO you at least readed some info about DMX and their timing charts?
anyway, 512 channel will need 9 dip switch indeed. so at least one 8bit pot + another elsewhere.

DMX VAR WORD

DMX.LowByte=PORTB
DMX.8=PORTA.0

The above give you the switch setting, now you just need to be in synch with the DMX break... then count untill you reach the right channel. How to? I know how AND i know my name will NEVER appear on your school report... so try few things, understand how serial communication works at least... then once you have understand it and read ALL links i already sent on various post... we can talk about a little bit more help.

Google have tons of DMX example... even using the most stupid controller in whole world.. 16F84. Ok it was good 10 years ago....

http://www.dmx512-online.com
http://www.erwinrol.com/index.php?stagecraft/dmx.php