Show Posts
Pages: 1 ... 404 405 [406] 407 408 ... 582
6076  Using Arduino / Programming Questions / Re: Reading in ASCII through serial on: August 07, 2011, 10:37:17 am
Quote
the ASCII output for the IMU in the serial program looks like this:
The above isn't ASCII though so I would think it's more a case of "why are there any TABs at all?" rather than "where have all the TABs gone?"

buffer should probably be "unsigned char" or "byte".

______
Rob
6077  Using Arduino / LEDs and Multiplexing / Re: 595 & 4021 multiplexing on: August 07, 2011, 05:49:48 am
Quote
I don`t have to push any button, and I get this.
It looks like the data is essentially random, you should get all 1s or 0s. Are you sure the SR is connected correctly?

______
Rob
6078  Using Arduino / LEDs and Multiplexing / Re: 595 & 4021 multiplexing on: August 07, 2011, 05:45:44 am
That code prints the raw value then several chars from an array.

So what numbers/characters are you seeing?

Are you sure the SR is connected correctly?

OK, crossed posts. I'll have a think.

______
Rob
6079  Using Arduino / LEDs and Multiplexing / Re: 595 & 4021 multiplexing on: August 07, 2011, 04:59:26 am
I can't find that "What is pressed" code, can you post it here.

How are you sending the data to the serial monitor?

If you are doing Serial.print (x) and x = B00000100 then you won't see anything because B00000100 == 4 and that's not a printable character.

Try Serial.print (x,HEX) or Serial.print (x,BIN)

______
Rob
6080  Using Arduino / Programming Questions / Re: Reading in ASCII through serial on: August 06, 2011, 11:20:48 pm
Quote
i just looped it which (i think) will display each value of the buffer in sequence:
That's what I meant by

Quote
you have to scan the array and send each byte with

print(buffer[index],HEX);

That looks like sign extension to me. Is buffer[] still an array of char, or did you change it to long?

If we ignore that, the first two "packets" have

Code:
A TAB C5 1 E7 1 22 1 F5 1 E8 1 EC 1 EC Z
A TAB BE 1 E7 1 21 1 F4 1 E7 1 EC 1 EA Z

or maybe

Code:
A TAB C5 1E7 122 1F5 1E8 1EC 1EC Z
A TAB BE 1E7 121 1F4 1E7 1EC 1EA Z

and in decimal

Code:
A TAB 199 487 122 501 488 492 492 Z
A TAB 190 487 121 500 487 492 490 Z

Do those numbers make sense to you?

______
Rob



6081  Using Arduino / Programming Questions / Re: Reading in ASCII through serial on: August 06, 2011, 09:03:59 pm
I'm getting a bit lost now, I thought we had established that the data was in binary format.

If that's the case you cannot use print(buffer), you have to scan the array and send each byte with

print(buffer[index],HEX);

OK, now I see this

Quote
i changed the inertial measurement unit's output from binary to ASCII,
With the data you are showing I can only assume that it is still not transmitting ASCII, if it was you would see meaningful characters (with the possible exception of the TAB, I don't know what the serial monitor would do with that).

Do the loop to print buffer contents in HEX, that's the only way to see exactly what you are getting.

______
Rob
6082  Using Arduino / Networking, Protocols, and Devices / Re: Serial Arduino on: August 06, 2011, 11:21:58 am
Quote
I'm pretty sure that a three digit array wont accept any more elements, and they'll simply be ignored, as in earlier versions of C.
Only if that's how you write the code, C will happily trash the entire RAM no matter what size the array is. As it is if you get > 3 chars you start trashing memory.

But as we've said you don't need the array in the first place.

Using that delay() makes the code dependent on the bit rate of the serial line. Not good practice. If for some reason the characters come at a different rate or with some time between them you exit loop(). Then when you come back you reset i to 2 and start again, despite the fact that you may be half way through receiving your numbers.

______
Rob


6083  Using Arduino / Networking, Protocols, and Devices / Re: SPI Communicatio Preview on: August 06, 2011, 10:49:57 am
What you are looking to build is a protocol sniffer of some kind.

If you only want to see the data traveling in one direction it should be simple, connect the Arduino's SCK and either MISO or MOSI depending on the direction you want to capture, then write some code to print the values it reads off the SPI line.

If you want to see the data traveling in both directions things are much harder. You can do the above for one signal but also use the UART in SPI mode to get the data going in the other direction. (Just theory on my part, there may be a dependancy that stops the UART being used this way).

If the data rate is slow enough you can "bit bang" both MOSI and MISO. That would be pretty easy.

Even if the rate is high you could slow it down for the test, as long as a slow version is still valid for the test.

Next, for $30 you can get a Bus Pirate, I've never used one but I gather they can decode various protocols including SPI.

http://www.sparkfun.com/products/9544

And the best way to do it (IMO) is buy a logic analyzer like the Saleae for about $150.

http://www.saleae.com

______
Rob

6084  Community / Website and Forum / Re: New global moderators on: August 06, 2011, 06:25:52 am
More power to you mate, I'm not having a go, just trying to understand the selection criteria. (A bad side affect of being an engineer I guess smiley)

______
Rob
6085  Using Arduino / Networking, Protocols, and Devices / Re: Serial Arduino on: August 06, 2011, 06:20:37 am
You don't need j or i if you have a delimiter (the LF), and I don't see how that works anyway but if it does it does smiley

_____
Rob
6086  Using Arduino / Project Guidance / Re: Accessing USB input lines on Arduino Mega 2560? on: August 06, 2011, 06:16:41 am
Quote
I want to use an arduino for control because I hate implementing USB interfaces and the transparent USART is nice.
Quote
because the controller is a tested and professionally assembled module that has a nice clear abstraction barrier from the rest of my system.
That makes sense.

Do you need USB for the application or just for programming?

______
Rob
6087  Community / Website and Forum / Re: New global moderators on: August 06, 2011, 06:04:33 am
Crossroads, Coding Badly and AWOL I get.

Yot has 279 posts, Uwe has 8. Am I missing something here?

______
Rob
6088  Using Arduino / Project Guidance / Re: Up down counter issues on: August 06, 2011, 05:54:11 am
Quote
I do not take credit for the code
Good for you, because it's crap code smiley

Here's a rough example of a better way to do it (well 1 digit at least)

Code:
//   G F + A B
//   | | | | |   -> pins and segments they control
//   ---------
//  F|   A   |B
//   |---G---|   -> segments
//  E|   D   |C
//   ---------
//   | | | | |   -> pins and segments they control
//   E D + C DP

// Segments that make each number when lit:
// 0 => ABCDEF
// 1 => BC
// 2 => ABDEG
// 3 => ABCDG
// 4 => BCFG
// 5 => ACDFG
// 6 => ACDEFG
// 7 => ABC
// 8 => ABCDEFG
// 9 => ABCDFG

// Arduino digital pins used to light up
// corresponding segments on the LED display
#define A 2
#define B 3
#define C 4
#define D 5
#define E 6
#define F 7
#define G 8
#define GND1 9
#define GND2 10

// Pushbutton connected to pin 9
#define BUTTON 11

// Common anode;
// on when pin is low
// and off when pin is high
#define ON HIGH
#define OFF LOW

int count = 10; // current display count
int val = 0;   // digital input from button

//             A B C D E F G
int pins [] = {2,3,4,5,6,7,8}; // the Arduino pins that drive the segments

byte segments[] = { // you set the correct bits B7 = G, B0 = A
B00000000, // 0
B00110011, // 1
B00110011, // 2
B00110011, // 3
B00110011, // 4
B00110011, // 5
B00110011, // 6
B00110011, // 7
B00110011, // 8
B00110011 // 9
}


void setup() {
  for (int i = 0; i < 7; i++)
pinMode(pins, OUTPUT);
 
  pinMode(GND1, OUTPUT);
  pinMode(GND2, OUTPUT);
  pinMode(BUTTON, INPUT);
  ten();
}

void loop() {
  val = digitalRead(BUTTON);
  if (val == HIGH) {
    count--;
    delay(300);
set_segments (count);
  }
}

void set_segments (byte val) {

for (int seg = 0; seg < 7; seg++) {
digitalWrite(seg, val & 1);
val >>= 1;
}
}


I say "rough" because it's late and I've had a couple of beers, so it won't work and may not even compile but I'm just trying to show you that whenever you reach for the cut and paste keys that's a sign that arrays and loops are a better way to do things.

______
Rob

6089  Using Arduino / General Electronics / Re: Building or use an interrupt controller. on: August 06, 2011, 05:29:13 am
IO expanders like the MCP23017 will do this, 16 potential interrupts with latching.

______
Rob
6090  Using Arduino / Project Guidance / Re: Reprogramming Arduino from internet on: August 06, 2011, 05:25:10 am
Sounds like you have to write a custom boot loader. But it has to get and decode packets from Ethernet I guess, that's going to make it pretty large.

______
Rob
Pages: 1 ... 404 405 [406] 407 408 ... 582