Using pins to define device address
BobVal
Posts: 48
I am going to have 4 Javelins talking to each other
1 Master
3 Slaves
I have no idea how to do this, coding I can do, electronics DAA
Can I use 2 of the java pins to define each a different address· 00 01 10 11
Do I just take a 10K resistor and connect it to power to get a 1 and ground to get a zero·and then Read the pins?
Bob
1 Master
3 Slaves
I have no idea how to do this, coding I can do, electronics DAA
Can I use 2 of the java pins to define each a different address· 00 01 10 11
Do I just take a 10K resistor and connect it to power to get a 1 and ground to get a zero·and then Read the pins?
Bob
Comments
in the background so you won't miss data.
The slaves should have a receive Uart that is permanently running,
while checking for incoming data from the mainloop.
The master can start a transmit and receive uart for the slave it
wants to address. You could wire the master TX output to all slaves
RX input if you setup a protocol that includes a slave ID so only 1
slave will respond. That said, you could also wire the master RX input
to all slaves TX output. That would work if all non-addressed slaves
disable·their·transmit uart (and make the TX pin input) until they are
addressed.
························ +----[noparse][[/noparse]1k]
Slave1 RXpin
Master TXpin
+----[noparse][[/noparse]1k]
Slave2 RXpin
························ +----[noparse][[/noparse]1k]
Slave3 Rxpin
························ +----[noparse][[/noparse]1k]
Slave1 TXpin
Master RXpin
+----[noparse][[/noparse]1k]
Slave2 TXpin
························ +----[noparse][[/noparse]1k]
Slave3 Txpin
Further, all javelins share a common ground.
Edit: yes you can use 2 pins with a pullup register to supply
each javelin with a 2bit ID. I would suggest 00 for the master.
regards peter
Post Edited (Peter Verkaik) : 11/14/2008 7:35:56 AM GMT
Sorry for my lack of knowledge.
You said "Pullup Register" I put a 10K resistors from Pin 14 and from Pin 15 goint to VDD and wrote the following code:
//
// NEED to determine Processor ID
//
System.out.print("\n\nPin 14 = ");
System.out.println(CPU.readPin(CPU.pin14) ? "Is High" : "Is Low");
System.out.print("\n\nPin 15 = ");
System.out.println(CPU.readPin(CPU.pin15) ? "Is High" : "Is Low");
I always get low.
But as I am writting this I think I might see my problem.
Do I have to set the pin as input first : CPU.setInput(CPU.pin14) before reading it?
Also are the ANY pins that I should stay away from (reserved for something special)?
Sorry for so many posts, Just getting back into the Javelin, had put this project down for a long while (almost 3 years exactly - Health Problems, Retirement and building a new home) and now just getting back into it. It is for the new home so it is not that far behind.
I when off and first tried the C-Stamp and could only get about 1/2 the code I had written Java converted to C, into there processor before running out of link area, I guess the Javlin generates small code because in the debbuger I only see my programs using about 13K (and I now have almost 3 times the code I was trying to put into the C-Stamp), should have never wasted the money.
Bob
I normaly·use pull-ups (10k)·(and small series resistor 1k) combined with a 2pin header
so I can use a shortlink to make it LOW (to GND).
Your way would require a 3pin header but also works.
Upon reset all pins are inputs.
There are no special pins. Each pin can be used for all
available VP's.
regards peter
I was doing the following Pin.14
> 10K
> VDD
Pin.15
> 10k
> GND
Which is not working
I assumed 14 would be 1 and 15 0 giving me a 10 = binary 2 for Javeline chip 2
Now you said my way would require a 3 pin header?
I am starting to realize that I need to by some of these series resistor packs.
The Javelin Doc says:
Number of I/O pins 16 plus two dedicated RS-232 <
I thought there were two special pins
Bob
easy change of address. Hardwiring the pins
as you mention it is also possible but then
the javelin must always use the ID
as you hardwire the pins.
Using headers you can design one pcb·that can
work with·4 addresses.
The two dedicated pins are SIN and SOUT and these
are used to program the javelin. They are not
easy to use for anything else.
regards peter
I looked for series resistor packs at DigiKey and got these devices that were $123 and more (I am sure this is not what you are talking about).
So the term "Series Resistor Packs" must mean something else to them, can you give me a part number???
While we are talking about this, I am going to need to control one relay and I was reading posts and you said:
I would not drive relays directly from pins, no matter
what currrent they draw. I would use a transistor
or a ULN2003/ULN2803 to drive relays
Could you explain why?
my idea:
················· VDD
·················· |
················ [noparse][[/noparse]10k]
·················· |
·········· 1 o
+---[noparse][[/noparse]1k]----o Javelin I/O pin
···········2 o
············ |
············ V GND···· Jumper off = high, jumper on = low
your idea:
··········· VDD
·············|
···········1·o
·········· 2 o
[noparse][[/noparse]10k]
o Javelin I/O pin
···········3 o
············ |
············ V GND· jumper on 1-2 = high, jumper on 2-3 = low, jumper off = noise
With headers I mean pin headers in 0.1" spacing. You can get them in strips of 1x36
Secondly, as Uarts can be used bidirectional, you can limit the interconnection to a single line.
················ VDD
················· |
··············· [noparse][[/noparse]10k]
················· |
··· +
+----+----+
+
··· |······· |········ |······· |
·· [noparse][[/noparse]1k]···· [noparse][[/noparse]1k]····· [noparse][[/noparse]1k]···· [noparse][[/noparse]1k]
··· |······· |········ |······· |
··· o······· o········ o······· o
· Jav1···· Jav2····· Jav3···· Jav4
All javelins start with receive Uart. Give the javelin with ID 00 the lowest delay
before transmitting the initial message after powerup. This lets you synchronize the
javelins.Sequence becomes:
Master sends, slaves receive
Master changes to receive, selected slave changes to transmit
selected slave sends, master receives
selected slave changes to receive
This leaves all javelin Uart pins inputs. The 10k pullup ensures a high idle level
which means you must use nonInvert mode for the Uarts.
The 1k resistors protect the javalins in case two or more try to send
at the same time.
To control a relay it is best to use a transistor which keeps the current requirement
for the I/O pin low. An I/O pin CAN deliver 25mA but this then also has to be delivered
by the javelin onboard voltage regulator which then causes more heat on the javelin
module. Apart from the current, there is also to voltage peak to consider when switching
off a relay. This peak is usually suppressed with an anti-parallel diode accross the coil.
Finally, most relays need a coil voltage > 5V and using a transistor you can connect
one side of the coil to +12V, the other side to the transtor collector and the
transistor emitter to GND.
regards peter
Post Edited (Peter Verkaik) : 11/14/2008 5:14:24 PM GMT
I am not sure if I should start a new topic, but I realized that the DS1302 takes a DOW when setting it but does not care if the DOW really matches the MM/DD/YY
I have a ton of C++ routines to take ANY year and convert to Jualian Days and come up with the real DOW for the date (so I can set the clock properly with just the user giving me a MM/DD/YY)
The Math package is missing any funcstions for LONGs ( labs ) and all my routines use longs because I have to add on this constant 577,735 to get the proper julian days.
Looked on the Yahoo site to see if there were any long math functions and did not see any. I olnly need the long ABS function maybe I can just write.
Bob
http://tech.groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/rtc/
and you'll find classes for DS1307, X1227 and a software RTC.
All this makes use of a Calendar class that does calculate DOW (day of week) based
on the date specified by a Calendar instance. It does not require longs.
A DS1302 class can be found here:
http://www.parallax.com/tabid/430/Default.aspx
however, I never converted that class to make use of the Calendar class.
regards peter