A simple interface
fearnot
Posts: 13
I don't have a lot of programming experience with Javalin so I am not sure if my question is too simple or not as simple as I think. I have designed a system which ultimately outputs a 3-bit string of·High and Low·(5 volts and 0 volts) in series. These bits are simple binary, which tell me that machine number x is out of order. For example, output·being·011 means that machine number 3 is down and 010 means machine number 2 is down and so on. I have to display this number on computer screen. There are 7 machines and I get 111 when there is no machine to be reported.
·
3-bit output string is continuous and there is a delay of about 1 second between each 3-bit string segment. My question is that if I convert these to parallel and connect each of the 3 bits to say pin1, pin2, and pin3 of Javalin, can I read the input data continuously, convert it to decimal number, and display it on computer (or print it to a file using something such as PrintWriter). Pseudo code would be something like
·
// Listen to incoming input data infinitely
// when pin1 pin2 and pin3 are high or low, output the associated decimal number to computer and write it to a file for record (something like PrintWriter)
·
My questions are:
·
1- How can I continuously read the pins for high and low voltage
2- And display the list of all the numbers·I am getting on computer screen and keep track of all the numbers that I am getting·by updating a·file on computer.
·
Any help please?
Thanks in advance
·
3-bit output string is continuous and there is a delay of about 1 second between each 3-bit string segment. My question is that if I convert these to parallel and connect each of the 3 bits to say pin1, pin2, and pin3 of Javalin, can I read the input data continuously, convert it to decimal number, and display it on computer (or print it to a file using something such as PrintWriter). Pseudo code would be something like
·
// Listen to incoming input data infinitely
// when pin1 pin2 and pin3 are high or low, output the associated decimal number to computer and write it to a file for record (something like PrintWriter)
·
My questions are:
·
1- How can I continuously read the pins for high and low voltage
2- And display the list of all the numbers·I am getting on computer screen and keep track of all the numbers that I am getting·by updating a·file on computer.
·
Any help please?
Thanks in advance
Comments
then you best can connect all these to javelin pins 0 to 6.
If, on the other hand, you receive a 3bit stream from your machines,
then you must·measuring pulses.
So how exactly report the machines their state?
regards peter
·
The whole project in fact is to get the machine number that encounter errors of any type·and display the results.
·
I actually have the program working on Netbeans by enterning the machine number using the keyboard·and this is how the program work
·
1- Reads a file and generate an array of all the machines with their locations and their IDs
2- Reads the ID number of the machine with error (reading from the keyboard at this time, but I want it to read ID from the real 3-bit serial data)
3- Searches the ID number it gets (from the keyboard for now) in the array created in "1" and display the matched machine ID and Location
·
2 and 3 are continuous. Following is the screen shot of it
which is only for simulation I assume.
regards peter
Thanks
bytes using a uart object, and the lowest 3 bits
of every byte hold the 3bit number?
regards peter
Your machines have signals connected to inputs 0, 1 and 2.
The inputs 3 to 7 are not used. This bitstream is wirelessly
transmitted and then received, so basically the javelin
receives 8bits per second, of which only the lowest 3 bits
hold information. That is not serial data because there
are no start and stop bit.
If you could make input 7 of the 74165 permanently high,
then you get a pulsetrain 10000xxx every second
(assuming MSB sent first) or xxx00001 every second (LSB sent first).
What is the rest level of the receiver dataline, that is the
level inbetween packets of bits?
If it is low, and the MSB is sent first, then
the·javelin can trigger on a rising edge after a 1 second low period.
regards peter
Thanks
Post Edited (fearnot) : 8/5/2006 10:57:54 PM GMT
If that clock frequency is slightly off then
at some point you will clock at the wrong times.
What is the clock frequency used with the 74165?
This tells us the bitperiod.
regards peter
Also, I am not sure if I understood the need of precise synchronization of clock in 74164. If Javalin reads pins significantly faster than the clock speed for 74164, how would it miss parallel inputs. After connecting 3 parallel inputs to javalin pin0, pin1, pin2, will something like this not work?
while (true){
int i = 0;
int j = 0;
int k = 0;
if (CPU.readPin(0) == true) i = 1;
if (CPU.readPin(1) == true) j = 1;
if (CPU.readPin(2) == true) k = 1;
// now I will have a 3-bit binary string
Formula to convert binary to decimal
Write to file and write to JTextArea
CPU.delay(5000);
}
am I on the right track? If not, how could I use UART? I have never used UART before.
Thanks
only then the parallel outputs of the 164 are equal to the parallel
inputs of the 165.
Creating a serial stream from the 165 serial output isn't that easy.
I still think a bitstream of 1000xxx is detectable.
Can you set the unused inputs of the 165 to any desired level
or are they fixed by the board the 165 is mounted on?
regards peter
·
Thanks
76543210
76543210
intermittent transmission of 8 bits
or
765432107654321076543210· continues transmission of 8 bits
regards peter
10000xxx (intermittent transmission)
Also, I was just reading Javalin API for its classes details, and I don't see any class like PrintWriter which could write my output to a file on computer. Since I don't think that Javalin has JTextArea or Pane etc, so I would probably have to write the results to a file. Then using Netbeans or any other IDE, I would read the file and show the results as shown in the screen shot above. Is there a better way of doing it in Javalin?
Thanks
period the receiver output is low,
how about this:
10XXYYZZ
where XX, YY and ZZ are the 3 bits.
So instead of using only the lowest 3 bits, use the lowest 6 bits,
connecting the 3 signals to inputs 0 and 1, 2 and 3, 4 and 5 of the 165.
This assures the pulsewidth of the 3 bits are twice the pulsewidth of the
start bit.
The pulse train than looks like
10XXYYZZ0000000000010XXYYZZ00000000000
You can then use pulseIn() to detect a positive pulse.
If the width is small then it is the startpulse.
I attached a small program to give you a start.
regards peter
Post Edited (Peter Verkaik) : 8/6/2006 9:41:53 AM GMT
Any comments on writing file or GUI display?
Unfortunately the IDE does not allow logging to a file.
Fortunately I have written a pc application that does.
It is called JideWin Terminal, located here:
http://groups.yahoo.com/group/JavelinCode/files/JideTerm/
After programming the javelin, close the JIDE program,
then start the JideWin program.
It allows you to name a log file.
Any received message from the javelin is logged to that logfile,
as well as displayed to the screen.
regards peter
I know I am probably asking too many questions but I spent many hours yesterday to read the serial string with the help of your program, but all I got were random values. I had exact 20 Hz and changed different delay and startbit values etc. in the program but no luck. I produced 10xxyyzz and xxyyzz01 but nothing worked. When I place LEDs at the output, the string is just fine. Is there another option of reading this serial string?
Also, I checked the specs of 74164 and you were right, it's not so easy to synchronize the output since bits are shifted as in a serial register. However, what if I make the first bit 1, following zeros and then the bits i.e. 10000XYZ, and then place the last pin on 74164 to one on Javalin and make checks for this pin to be high. My concept is that when the last pin on 74164 is high, then the bits on first three pins on 74164 are ready to be read. So connect first three pins on 74164 to pin0, pin1, pin2 on Javalin and Last pin of 74164 to pin4 and something like,
while(true){
if (CPU.readPin(CPU.pin4) == true)
//Read pin0 for bit0 pin1 for bit 1 and pin2 for bit2
…..
What's your opinion about something like this? Any other way to get bits from the output line?
Thanks so much
To find out the correct value for variable small,
make sure input 7 of the 165 is tied to 5V,
the other inputs (0-6) of the 165 tied to 0V.
That should generate 10000000
10000000
so the only positive pulse is the startbit.
The example program I provided will then display
the width value for this pulse.
If that value is, for example, 4312 then make small = 4312.
Then reconnect the signals to inputs 0-5 in the order XXYYZZ.
The question is how long it takes to transmit the 8bits and how long
the
period is. If the
period is very small,
then the printing statements may take too long so the next startbit
is missed.
If possible, try to send the 8bits in 0.25 sec or less, leaving 0.75 sec or more
for the
period. The javelin prints its output during the
period.
Can you post the schematic for the transmitter connected to the 165
inclusive the cicrcuitry that generates the clock signals.
Then we may get a better idea how exact the bits are transmitted.
regards peter
Actually, now I am facing another problem. I tested the transmitter and receiver, and when I transmit 5V at the transmitting end, receiver does receive 5V at its data line. However, when I ground the data line of transmitter (i.e. send 0V), receiver for some reason still has 3V. So the logic 0 and 1 in transmitter and receiver is not 5v 0v but 3v and 5v. I tried to use comparator but can't figure it out.
I tested Javalin, and it takes 2.5+ Volts as 1 and less than 2.5V as 0. Is there a way on Javalin to sense anything less than 4v as 0 and greater than 4v as 1? Or any other suggestion?
Thanks
http://www.parallax.com/detail.asp?product_id=28180
If not, correct me.
The manual of the receiver states on page 3:
Calibration
When initiating communication between the RF modules, a sync pulse should be sent to re-establish the
radio connection between the modules. Sending several characters can accomplish this, however
sending a pulse (which maintains a high state during the synchronization) is more efficient:
√ For BS1s the following code line sends an appropriate sync pulse:
PULSOUT 1, 300
√ For BS2s the following code line sends an appropriate sync pulse:
PULSOUT 8, 1200
√ For Javelin Stamp modules the following code line sends an appropriate sync pulse:
CPU.pulseOut(300, CPU.pin8);
(Note: this line assumes that I/O pin 8 is connected to the DATA line on the transmitter)
According to the last line (javelin) the sync pulse duration is 300*8.68uSec = 2.6mSec
So it seems that you must send a high pulse for 2.6mSec first, then the bits from the 165.
It is not explicitly mentioned in the manual, but I don't think the receiver outputs
anything if it has not received the sync pulse.
The simple solution for your problem is using a BS1.
This has 8 I/O lines so you can use 7 of those for your machines,
and one to connect to the transmitter.
That allows you to receive uart data on the javelin (see manual for example code).
regards peter
I finally got the synchronization to work. Thanks for all your help!
I tried to use your WinJide Terminal but when I execute the exe it gives me an error "The application failed to initialize properly." Please let me know how could I log the System.out's messages saved to a file.
Thanks
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en
Could you post the part (or whole) of your program
to show how you managed synchronization?
regards peter
·