Show Posts
Pages: 1 ... 424 425 [426] 427 428 ... 593
6376  Using Arduino / Networking, Protocols, and Devices / Re: More than one Slave RS232 on: July 22, 2011, 09:46:50 am
Quote
Can I use it just like RS 232?
You can use 485 like 232 but not the other way around.

RS-232 is not suitable for a multi-drop bus because you cannot disable the transmitters. That's why RS-485 is popular because the transmitters can be tri-stated to allow others to talk.

Quote
Is there any good tutorial on RS 485?
I haven't looked in the last 20 years so don't really know but did a bit of Googling

http://www.lammertbies.nl/comm/info/RS-485.html
http://www.radio-electronics.com/info/telecommunications_networks/rs485/rs-485-tutorial-basics.php
http://www.bb-europe.com/tech_articles/rs485_basics.asp
http://www.bb-elec.com/tech_articles/rs422_485_app_note/table_of_contents.asp

I'm not sure these are good but they should give you the idea.

Quote
How does Slave to Master works?
Basically the master asks a slave for information or sends it a command, and the slave provides the information or actions the command.

Usually this is done by sending a "packet" to the bus, this packet has control information such as slave address, data length and a checksum. The slave responds either with data or just an acknowledge so the master knows the data/command was received. The master then moves on to the next slave address and the process repeats until all slaves have had a go. Then the master goes back to the first slave etc etc.

This is called a "protocol" and there are a 1000 variations. AFAIK no (simple) standard exists so you have to write your own protocol. Writing a robust protocol is not a simple job, however something quick and dirty is easily achievable. As this is for a model railway nobody will die if some data is corrupted, that always helps smiley

______
Rob
6377  Using Arduino / Programming Questions / Re: Reading and writing Serial at the same time with Arduino + Processing. possible? on: July 22, 2011, 09:16:57 am
Quote
kickStatus = !kickStaus;
I see you found the typo in the previous post then smiley

I don't see how the Arduino reading and writing to the USB can in itself cause the port to be closed, having the two talk to each other on the same port is normal. So I think it has to be in your Processing code. I can't see anything there either but I have limited Processing experience.

______
Rob
6378  Using Arduino / Motors, Mechanics, and Power / Re: Battery readings? on: July 22, 2011, 09:07:20 am
I'm just designing the hardware for my monitoring system now so won't be into the coding for some time.

I will however be able to read the current so should be able to make decisions based on that as well which will help.

Yes more batteries would be nice, but I only have room for 10 and as you say the microwave doesn't get used much. Also my current shunt is located about 2.5 metres from the actual batteries, the wires are thick but with a 70A draw I may be losing Vs in them or in the connections. Something I should test one day.
______
Rob
6379  Using Arduino / Microcontrollers / Re: Testing whether a pin is an interrupt on: July 22, 2011, 08:58:02 am
Quote
Great! I can just auto-include that file!
I think you still need to organize your own include file, io.h in turn includes ioxxx.h depending on the chip that's being used. However that included file does not have any definitions for the interrupt pins AFAIK. I am suggesting that you can use io.h as a template to create your own file in the format you need.

Quote
all of the I/O pins can generate a 'Pin Change Interrupt'.
Good point Don, I was assuming just the external int pins.

______
Rob


6380  Using Arduino / Networking, Protocols, and Devices / Re: More than one Slave RS232 on: July 22, 2011, 08:42:37 am
The serial signals on Arduino are not RS-232, that is an electrical spec that specifies voltage levels among other things.

So, apart from that yes you can link several Arduinos on a serial connection, you just have to choose appropriate line drivers and for this sort of thing RS-485 is normally the recommended standard.

With RS-485 you implement a "half duplex" connection, which basically means only one device can talk at a time, so you do what you have been thinking, a master sends a packet to the "network", all slaves read this packet and the addressed slave takes action on it.

Depending on the nature of your application (ie how important the data reliability is) this can be very simple or quite complex.

Quote
long cable length
How long and how fast?

______
Rob
6381  Using Arduino / Programming Questions / Re: 'class String'has no memeber names 'setArray' on: July 22, 2011, 06:34:45 am
Looking at the code it seems that all get/setArray does is an assignment, so I think you can make the following substitutions

Code:
TextString lcdOutput = TextString( 9 );
 lcdOutput.setArray("108.0MHZ" );    // Just a template...

to
 
Code:
TextString lcdOutput;
lcdOutput= "108.0MHZ";    // Just a template...

and

 
Code:
lcd.printIn( lcdOutput.getArray() );

to

 
Code:
lcd.printIn( lcdOutput );

The only other member you use is setCharAt() and this does seem to be supported by the String class.

EDIT: Actually you overwrite the "108.0MHZ" anyway in the following code so there's no point assigning that default string.

______
Rob

 
6382  Using Arduino / Programming Questions / Re: 'class String'has no memeber names 'setArray' on: July 22, 2011, 06:12:07 am
I had no idea what class TextString was so went and had a look. Looks like it's been replaced by String and String doesn't have those two members, normally in that case I would look at the code for get/setArray in the old class, see what it does and see if there's a member in the new class that does the same thing.

Unfortunately TextString doesn't appear to have those members either so I don't know where that code you have got them from.

I'll have a look at your code and see if I can see what it's doing and recommend a change.

______
Rob
6383  Using Arduino / Programming Questions / Re: 'class String'has no memeber names 'setArray' on: July 22, 2011, 05:00:28 am
Class string does not have that member AFIAK, you have declared "lcdOutput" as a TextString, what is that. Presumably not a String.

If you just changed TextString to String and String doesn't have setArray/getArray member then it won't work.

______
Rob
6384  Using Arduino / Displays / Re: 4D LABS μLCD-32PT(SGC) 3.2” Serial LCD Display Module Arduino Library on: July 22, 2011, 04:42:02 am
I guess they thought auto sizing is a good idea, which on occasion it is, but I think fixed button sizes are better most of the time.

______
Rob
6385  Using Arduino / Sensors / Re: Thermocouple amp with MUX on a mega on: July 22, 2011, 01:01:36 am
I always thought it was not a good idea to run t-couples through a MUX, still if it works it works.

Code:
while(1)
  {
    delay(1000);
    Set_Mux_Channel(1); <<<<<<<<<<<<<< should be a variable, not 1

You never select the other channels. Also you don't need the while(1) but it doesn't do any harm.

Quote
you can have multiple SPI devices provided you use different CS pins?
That's normally true, but I'm not familiar with the SPI library so don't know how it does the CS stuff.

______
Rob
6386  Using Arduino / Programming Questions / Re: Virtual switch on: July 22, 2011, 12:50:56 am
Quote
All I need to do really is touch two wires together momentarly.
The problem is you don't know exactly what's on those two wires. It is possible that just applying a logic level to one of them and GND or 5V to the other will work, but you don't know that without proper documentation.

Therefore the only safe way is with a relay of some kind.

Get some proper data and there may be other options.

______
Rob
6387  Using Arduino / Programming Questions / Re: 12 button Keypad input into a string on: July 22, 2011, 12:39:58 am
You simply get the characters one by one and add them to an array. Something like this

Code:
char password[5];  // one extra char to null terminate the string
memset (password, 5, 0);  // clear the array
for (int i = 0; i < 4; i++)
  password[i] = getKey();

I'm not familiar with the keypad library and I've assumed getKey() doesn't return until a key is pressed. If getKey() returns a value indicating there was no key pressed the code would be more like this.

Code:
char password[5];  // one extra char to null terminate the string
memset (password, 5, 0);  // clear the array
int k;
for (int i = 0; i < 4; i++) {
  do {
     k = getKey();
  } while (k == -1);
  password[i] = k;
}
______
Rob

6388  Using Arduino / Programming Questions / Re: How do you program Machine Lauguage into Arduino / ATmega on: July 21, 2011, 11:10:04 pm
Quote
using digitalWrite ( pin, State ) Does Not Send at the same time.
That's true, however if that's all you need to do then you don't need to drop into ASM, C code like

PORTB = 0x55;

Will be just as good.

______
Rob
6389  Using Arduino / General Electronics / Re: Microcontroller? We don't need no microcontroller! on: July 21, 2011, 07:59:26 pm
Quote
Maybe we should have another thread ...
Yep, maybe under Exhibitions or Bar sport. I'm sure there's a lot of old projects people would display.

______
Rob
6390  Using Arduino / Microcontrollers / Re: Testing whether a pin is an interrupt on: July 21, 2011, 07:53:45 pm
In the Arduino install

C:\Program Files\Arduino\arduino-0021\hardware\tools\avr\avr\include\avr

there is a file called io.h

This has includes for every AVR type based on a value defined elsewhere (maybe on the GCC command line although I don't see it there).

Anyway if this definition is always in place (and it has to be to get the right processor include file) you can use that to have a processor-specific #define.

______
Rob
Pages: 1 ... 424 425 [426] 427 428 ... 593