Show Posts
Pages: 1 ... 47 48 [49] 50 51 ... 55
721  Using Arduino / Programming Questions / Re: Sunion RFID RFM-003 with Arduino on: November 23, 2011, 01:37:58 pm
Hi Have this so far, But NO Luck at all

          Serial.println(" >> Prepare Scanning");

A few things.

1) Serial.println() is very slow -- it will significantly impact your timing. I highly recommend toggling a digital out pin with a LED or something if you want to know that the code gets to a particular point. Or use an oscilloscope or logic analyzer.

2) If ResetRFID() works, it should work the first time. Trying it three times is voodoo programming, and is actually hurtful, not helpful.

3) There is no such thing as a "delay50ns()" function call on the Ardiuno. At 16 MHz, there are 62.5 nanoseconds per clock, so a simple NOP instruction delays more than 50 nanoseconds (and this doesn't take the call and return instructions into account).

722  Using Arduino / Programming Questions / Re: Sunion RFID RFM-003 with Arduino on: November 22, 2011, 08:13:14 pm
Sorry, I read more in that data sheet, and you may be up against a bit more than you signed up for...
Specifically, the data code looks to be self-clocked, with a fixed pulse width. You need to detect the pulse width yourself, and then clock the input according to that pulse width. The range is 250-320 microseconds per pulse, using some form of phase shift keying for 0 vs 1 data.
Interestingly they call this "Manchester code data," but last I learned, "Manchester" data is 1-high, 0-low. Also, given that the pulse width is in microseconds, I wonder if the reset/clock timings they specify in nanoseconds really should be in microseconds.

You probably want a 100 MHz oscilloscope with at least two channels, and/or a logic analyzer with similar performance, to figure this guy out.
723  Using Arduino / Programming Questions / Re: Sunion RFID RFM-003 with Arduino on: November 22, 2011, 08:07:37 pm
Given that it has SCL and SDA signals, it looks as if it might be using I2C. If that's the case, you should connect SCL and SDA to analog pins 5 and 4, tie them to +5V through a pull-up resistor of about 2.2 kOhm each, and then use the Wire library to talk to the reader:

... nevermind. I looked on page 7, and it may be that it doesn't actually do I2C but instead a custom protocol that doesn't use address codes. Thus, you'll have to write your own library that generates the output clock signal and generates/reads the data signal, probably on two digital pins, such as D2 and D3. Use pull-down resistors (10k?) to D2 and D3, and tie those to CLOCK and DATA respectively. The reset sequence (as shown on page smiley-cool would look like:

#define CLOCK D2
#define DATA D3

pinMode(DATA, OUTPUT);
digitalWrite(CLOCK, 0);
digitalWrite(DATA, 0);

// reset
digitalWrite(CLOCK, 1);
digitalWrite(DATA, 1);
digitalWrite(CLOCK, 0);
digitalWrite(DATA, 0);

Note that the timing is specified in nanoseconds, so you'll be running the device slower than specified, because the Arduino really only makes sense at microsecond intervals. (There are 1000 nanoseconds in one microsecond).

You should be able to drive the output for sending the commands suggested in the data sheet, and turn around the pin mode for reading inputs (hopefully the timing will allow this!)
724  Using Arduino / Programming Questions / Re: DAC Counts Question on: November 21, 2011, 08:45:12 pm

example 11.5 & 12.5. Using 3 analog channels One for reading 0 to 5v and converting this to 0 to 20 volts. Channels 2&3 are

I'm assuming you're talking about ADCs. Those read values between 0 and Vref (which defaults to 5V). You need to map the input voltage range you want (say, 11.5 to 12.5 V) to the range that can be read (say, 0V to 5V).
The easiest way to do this is with an operational amplifier, assuming you have the appropriate voltages available. Either get +18V / -18V to the board, or get a boost/buck voltage converter to get the voltage spread you want.
Then, wire a reference voltage to the "-" input on the opamp. This is your "0" level. You can make this trimmable by wiring one potentiometer between +18V/-/-18V.
Second, wire the input to the "+" input.
However, you likely also need to feed back the output to the input side, to avoid too much amplification.
Now, wire the output of the opamp into the ADC pin you want to read. Trim the first potentiometer so the input value reads as 0 when you have the bottom value, and trim the second potentiometer so you read 1023 when you have the max value. Depending on the wiring, these may also be co-dependent, so you have to re-trim until you get the range you want.

Note that this is all in the external circuitry -- the Arduino has nothing to re-map voltage ranges internally.
725  Using Arduino / Programming Questions / Re: digitalWrite does not trigger Relay on: November 21, 2011, 08:32:33 pm

If you want to drive it from the Arduino, that's not right. It takes commands from USB, which is not something the Arduino outputs (as a master).
Also, it already has relays, that go to 16 A -- but only 8 volts. Thus, you'd be using relays to drive relays, which sounds quite expensive! All you need are some transistors hooked to the output pins to buffer the relay coils.

The second module is similarly not what you want, as it takes serial commands rather than Arduino pins. Now, you can make Arduino pins send serial commands, but you may still need to add wiring to boost the 5V I/O of the arduino to that serial voltage needed by the board -- I don't know how low voltage it can accept.

If I were you, I would do one of three things:

1) Get a good set of Triac (solid state) relays. Sharp has a line that does 8A / 120V and is about $8 each from Digi-Key. You can drive the trigger of these directly from the Arduino, because they don't use much current. Draw-back: you can't put more than 8 A AC current through them before they burn out, and they do need a cooling plate at that power level. (That's 1000W each, though!)

2) Get a prototype board, and solder/push some transistors in. Some nice 500mA/80V MOSFETS for a quarter each ought to do the trick. Wire the relays from +5V to the collector, wire the base to the Arduino pin out with a 1kOhm resistor, and wire the emitter to ground (if I remember correctly). That's all the buffering you need.

3) Get a more appropriate relay board; ideally one that already can drive the main power loads you're interested in. This one looks promising (as long as you don't need more than 8A per channel): -- $26

And, most of all -- read all the specifications and run the numbers to make sure that you don't exceed any of the limitations of the devices you hook together! If you're driving a space heater or air conditioner with your mains relays, then it may very well need more than the 8A I've suggested above. If you're driving a stereo or a floor lamp or something, you should be safe.
726  Using Arduino / Programming Questions / Re: Can I code a small java application to commuincate with my arduino? How? on: November 21, 2011, 08:20:17 pm
I'm pretty sure it's possible, but I was wondering if it can be done. I recently got into Java and I've learned a lot. The other day I had the idea that I'd see if I can create a java applet to let me cotrol which LED's turn on and off through my Arduino. Any help is appreciated smiley

Easiest is to use the serial port. You can write a sketch that reads from the serial port, and writes to the output ports based on what it reads -- this is fairly simple.
Then, open a serial port from Java, just like the Arduino IDE does, and write commands to the board while it's running. The commands will go over the USB-serial connector and be available to your sketch running on the board.

There are, of course, many more advanced ways of doing these things, but I think such a simple sketch would be a great start.
727  Using Arduino / Programming Questions / Re: Sampling Rate on: November 21, 2011, 08:10:56 pm
[quote author=CrossRoads link=topic=79714.msg602336#msg602336 date=1321844912]
unsigned long currentTime = micros();
for (x = 0; x<100; x=x+1){
while ( (micros() >= (x*125000UL) {

That looks like an infinite loop to me. It also looks like it will sample at 8 Hz rather than 8 kHz.
I imagine what you really meant was to make the while() statement look like:

while (micros() - currentTime < (x + 1)*125UL) {

And, because micros() is a function, and you're doing 32-bit math, the loop itself probably has significant overhead. But at 16 MHz, you do 2,000 instructions per 8 kHz sample, so as you say, you'll probably be running the loop many times per sample (which isn't bad in itself).
728  Using Arduino / Programming Questions / Re: Why most of people using "foo" a name of variable on: October 18, 2011, 10:40:30 pm
I have seen many forum/programmers post where people are using "foo" as a name of variable or function.. Whats the story behind it?

It's a programmer tradition. It's a short variable name you can use when you don't want to go through the effort to come up with a descriptive variable name.
729  Using Arduino / Programming Questions / Re: String Nightmares and More on: October 17, 2011, 03:52:48 pm
programmers.txt) so it was recognized. Then the sketch uploaded OK. However afterwards when I went back to the "normal" bootloader programming (via the USB port on the Uno) it kept timing out. I eventually worked out that using this other programmer had "wiped the bootloader"

My guess is that your uploading the sketch actually *replaced* the bootloader. If the available memory is 32 kB, the normal upload process protects 2 kB for the bootloader, and gives you 30 kB for the sketch. However, with a bit-banger programmer, I imagine that all 32 kB is available for your sketch, and it ignores the bootloader and overwrites with your sketch. If you want to go back to serial-based boot loader, you'll have to re-program the boot loader using the bit-banger again. (I generically use "bit-banger" for any programmer that doesn't go through the 2 kB bootloader serial interface, but instead uses lower-level methods)

730  Using Arduino / Programming Questions / Re: String Nightmares and More on: October 16, 2011, 11:03:43 pm
I'm currently working on a ground station transmitter controller for a satellite that I helped build over the summer. It's getting ready to launch October 27th, so I'm in a bit of a hurry to get the final touches on the software end of things to control the transmitter. Here's what I've run into tonight:

You know, the AVR chips and the Arduino platform are fantastic little widgets that allow you to add a bit of intelligence to all kinds of things (anything from light switches to costume hats to beer dispensers :-)

However, they are not "the" solution for all possible embedded systems.

When it comes to "satellite controllers" with command-line interfaces, I'd suggest using something more like a WRAP/ALIX box or a Cortex M3 based board or similar. Examples:

ARM based boards:
(the board + software is $59)

Do you want a nice, 3.5" touch screen with your controller, and gobs of RAM as well? (Think "smartphone innards") ($109 -- 128+2 MB flash, 64 MB RAM)

ALIX box (linux based): (ALIX 3d2 is $99)

What you don't get with those systems is a support community, though. If that's what you want, how about a $199 system that you can develop on, AND surf the web on, AND end up sticking in whatever enclosure you'll end up using? It can provide all the buttons and user interface you want.
Buy a netbook!

The closer to a "real" computer you get, the less you get "general purpose" I/O that you can hook motor drivers or whatever into.
If the reason you're using an Arduino is that you need to hook up various I/O, then perhaps the right choice is a computer interface on a bigger box, and the Arduino is simply an I/O driver controlled by that bigger box using some simple serial protocol? You can have a user-friendly UI on the bigger box, because the serial protocol can be simple and only needs to worry about the needs of the machines.

731  Using Arduino / Programming Questions / Re: Call random() from interrupt service routine? on: October 16, 2011, 10:29:52 pm
The short algorithm you posted replaces probably a hundred lines of my old code  smiley-mad

Glad I could help :-) Don't know what to do about your interrupt problem, though.
732  Using Arduino / Programming Questions / Re: Fastest way to do sin(), cos() atan2() on: October 16, 2011, 10:27:16 pm
- max error: 0.00015676  == compared to sin()
- avg error: 0.00004814

That's only 10 or 11 bits of precision. If you're doing this on GPS coordinates for vehicles, then your error may put you ten kilometers off...
In fact 24 bits mantissa (which is all you get from "float" or "double" on Arduino) puts the error on the order of several feet at the surface of the Earth.
I guess it's important to understand what the application is and what kinds of errors are acceptable or not if you want to optimize more...
733  Using Arduino / Programming Questions / Re: self service bar Program help on: October 16, 2011, 10:20:23 pm
He has a flow meter that takes care of point 3, and indirectly point 4

Yes, I missed that -- makes that part easier!

In addition though, it would be nice if there was a way to interface the netbook to the POS system

Yup! Although most cash registers really don't know how to send a message to "please update the database to add X credits for card Y" so in reality, I think most users of such a system wouldn't benefit.
In fact, you'd probably be better off making the netbook *be* the POS system ;-)

Regarding backups, if the cards store value across nights, I would agree. If the system is available only for a night (say, it's a rental or similar), and goes down, unless you keep a second netbook on hand with ability to restore from (near-real-time) backups, the backups of the cards won't help much. If the idea is that this is for a party rental store or whatever, then I'd probably want to ruggedize everything and have a "hot backup" just in case. Cost becomes a factor, too.

Man, this sounds like fun. I wish I was the one building this system :-) :-)
734  Using Arduino / Programming Questions / Re: self service bar Program help on: October 11, 2011, 07:55:20 pm
Yes the idea as changed from a box to a RFID card ... Are you saying robs idea would work or not if so can some one tel me how to do it ... Thanks for your replys just hope I can work this out

What I would do is build each Arduino as a simple I/O device. It would have functions to:
1) detect the presence of a card, and report that on network
2) receive instructions to allow dispensing beer from the beer
3) time the dispensing of beer (so you know how much has flowed through) and report on the network
4) report on level of beer in keg (so you know when it's time to refill which unit) and report on the network

I would then build a simple, central system that manages between 1 and <many> beer dispensers. This would be built using something like a WRAP or HARP box or perhaps a cheap "netbook" (that comes with keyboard, display, and hard drive). Probably running Linux, for a cheap system. This system should have UI that:

1) displays amount of beer from each connected dispenser
2) displays transactions from cards as they come in
3) stores and updates the amount of value related to each card
4) lets the operator add money stored to a particular card (you probably want a reader right by the system for this purpose)
5) lets you export transactions and information about the system (beer consumption, etc) for later accounting
6) receives requests for beer from the nodes
7) if there's enough credit, send back a "dispense" message; else send back a "no credit" message (for display to the user of the beer tap)
smiley-cool if some beer tap reports trouble, make this clear on the display

Note that netbooks can be had for about $200 *new*, and a lot less *used*. Add an Ethernet switch/hub, and an Arduino with Ethernet per tap, and you should have a pretty cost effective system.

Networked programming is hard, though (distributed systems have many failure modes!) and interacting with the real world (dispensing beer) is messy, so you're probably also in for an interesting time making it all work :-) Sounds like a fun project!
735  Using Arduino / Programming Questions / Re: reading push button at any time HELP on: October 11, 2011, 07:46:16 pm
which delays? the button ones? or are you referring in my entire code,
SMS for example needs some delay to allow the MODEM to respond before sending next line. 

The SMS needs you to not send more data before it is ready. That doesn't mean it needs a delay().
You could, for example, set a variable of what millis() was when you last sent a message. Then when you want to send a new message, compare (millis() - var) to see if it's yet time or not. Else, don't yet send the message; wait until you check again.

Also, if you save the value of millis(), make sure to update it every once in a while, as it will wrap around to 0 every few days.
Pages: 1 ... 47 48 [49] 50 51 ... 55