Show Posts
Pages: 1 2 3 [4] 5 6 ... 9
46  Using Arduino / LEDs and Multiplexing / LED driver ic. What devices do you all use? on: September 18, 2012, 02:28:49 pm
Hello forum,

Am just interested about what 16 bit LED drivers you all use? Do you prefer i2c or SPI? I have never used 12c or SPI before and am trying to get a bit of background on the most commonly used LED drivers around here. If i choose one that is used alot around here i may have a better chance on getting it to work.

Many thanks.
47  Using Arduino / LEDs and Multiplexing / Re: RPM LEDs code help. on: September 18, 2012, 02:17:21 pm
Thinking about using one of these http://uk.farnell.com/on-semiconductor/cat9532wi-t1/led-driver-16bit-program-24soic/dp/1656134
48  Using Arduino / LEDs and Multiplexing / Re: RPM LEDs code help. on: September 17, 2012, 03:28:50 pm
Food for thought is good, thank you. I do plan on using a LCD aswell to display engine load etc. I can get any info i want from the car now and display it in the serial monitor but i will be having lots of display items so am not sure how to code a routine to update all the displays with no visable delays. So far in the end i want 2 4 digit seven segment displays (1 for speed and 1 for voltage or something) a row of 8 LED's for RPM + 1 LED for the shit indicator and a LCD for as i said above) It's gonna be a lot of pins needed so i would like to use the i2c bus for all may display items.
49  Using Arduino / LEDs and Multiplexing / Re: RPM LEDs code help. on: September 17, 2012, 02:55:16 pm
Also am wanting to have a shift LED that will flash when the RPM gets to a pre set value via a rotary switch / hex switch.
50  Using Arduino / LEDs and Multiplexing / RPM LEDs code help. on: September 17, 2012, 02:48:37 pm
Hello all. I have a sketch that reads a cars ECU via OBD that all works great but now its time to move on and actually displaying some info. Am looking at using the i2c bus to control LEDs and seven segments but to start with i just want to use 8 LEDs to show RPM (1 LED = 1000RPM).

Code:
#define ERPM    0x0C //Engine RPM.

//Main.
void loop()
{
  unsigned long result = 0;
   
  get_PID(ERPM, &result);
  if(result <= 999)
  {
   // B00000000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 1000 && result <= 1999)
  {
    //B10000000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 2000 && result <= 2999)
  {
    //B11000000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 3000 && result <= 3999)
  {
    //B11100000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 4000 && result <= 4999)
  {
    //B11110000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 5000 && result <= 5999)
  {
    //B11111000 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 6000 && result <= 6999)
  {
    //B11111100 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 7000 && result <= 7999)
  {
    //B11111110 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
  else if(result >= 8000 && result <= 8999)
  {
    //B11111111 value to be displayed on 8 LEDs. 1 = LED on, 0 = LED off.
  }
}

A little info about the above, unsigned long result = 0; is a variable that will contain anything from 0 to 9000 and get_PID(ERPM, &result); is the command that gets the info from the car that works fine.

As you can see from the above that i want to turn on some LEDs over i2c (to the LED driver) to show the rpm. Am i better using some kind of for loop and place the binary valuse in a const struct or array or PROGMEN?

Any ideas or examples would be great. In the end i will be adding more i2c ic's to display speed on a seven segment.
51  Using Arduino / Programming Questions / Re: Bitshift question. on: September 14, 2012, 02:06:42 am
PID is a byte that may contain anything from 0x01 to 0x20 and SupportedPID20 is a unsigned long type.
52  General Category / General Discussion / Re: Best coding practice. on: September 14, 2012, 01:31:38 am
Back to my original post lol. So if you declare a function as a boolean then use return true or fales but if you declare the function as an byte, int, long use return 0 or 1?
53  Using Arduino / Programming Questions / Re: Bitshit question. on: September 14, 2012, 01:01:41 am
Sorry for not being clear.

Quote
That is a VERY large number, much larger than can fit into a unsigned long. Is that decimal or binary representation?

This is the binary representation of the number.

Quote
Can you modify that code to make it more obvious which block of code you're interested in having executed? There are three 'if' statements, two of which have an associated code block, and it's not obvious which of these five things you're talking about.

Yes and it's this part below mate.

Code:
else if(PID >= 0x01 && PID <= 0x20)
  {
    if(i << (0x20 - PID) & SupportedPID20);
    return true;
  }

The SupportedPID20 variable (decleared at the top of my code) will contain something like 11111111001111110001010111110111 binary (when running on a car) and lets say i variable will contain something like 00010000000000000000000000000000 binaray (if PID = 0x04). Am wanting to compare 1 bit so if bit 4 of SupportedPID20 is 1 and bit 4 of i is 1 will the if statment return true? Well thats what i want it to do anyway lol.
54  Using Arduino / Programming Questions / Bitshift question. on: September 13, 2012, 03:55:29 pm
Hello again.

Could someone please tell me if i am correct in thinking if that Supported_PID20 has 00010000000000000000000000000000 in it and unsigned long i has (well think it should have if my code is correct) 00010000000000000000000000000000 in it the if statment will be executed?

Code:
byte Check_Supported_PID(byte PID)
{
  unsigned long i = 1;
  
  if(PID == 0x00)
  {
    return true;
  }
  else if(PID >= 0x01 && PID <= 0x20)
  {
    if(i << (0x20 - PID) & SupportedPID20);
  }

Cheers ppl.
55  Using Arduino / Networking, Protocols, and Devices / Re: RS485 communication woes on: September 13, 2012, 02:26:33 pm
R3 and R2 are wrong. It should be 1 120ohm resistor across A and B. What type of RS485 network is it? Are you trying to transmit and receive from one MAX487?
56  Using Arduino / Networking, Protocols, and Devices / Re: How to use incoming serial data AND arduino serial monitor at the same time on: September 13, 2012, 02:15:38 pm
Why not use the software serial libaray to setup another serial com port on the arduino and then serial monitor if free then.
57  Using Arduino / Programming Questions / Re: HEX string to unsigned long. on: September 12, 2012, 03:09:45 pm
I notice you use use

var <<= 8;

does this mean the unsigned long variable fills from right to left?


Sorry just noticed your last post lol.
58  Using Arduino / Programming Questions / Re: HEX string to unsigned long. on: September 12, 2012, 02:58:54 pm
Quote
Do you mean you want the sum of those values (0x198) in a 32 bit variable, or the value 0xbe1fa813 in a 32 bit variable?
Hello mate, yes i want the sum 198 hex, 408 DEC to go into a 32 bit variable.
59  Using Arduino / Programming Questions / HEX string to unsigned long. on: September 12, 2012, 02:44:05 pm
Hello all. Little guidance needed on converting a HEX string for example char str[5] contains BE 1F A8 13. Am wanting to add the 4 bytes together and place the answer into a unsigned long. Would a simple for loop work for this with the += compound operator?

Many thanks as always.
60  General Category / General Discussion / Best coding practice. on: September 11, 2012, 02:27:06 pm
I have seen (none boolean declared) functions that have

return 1;
or
return true;

return 0;
or
return false;

if(i == 0)
or
if(!i)

i know they do just the same thing but was wondering if it's best practice in C++ to do one or the other or is it just personal preferance.
Pages: 1 2 3 [4] 5 6 ... 9