Show Posts
Pages: 1 2 [3] 4 5 ... 9
31  Using Arduino / Displays / Re: Video Amplifier Circuit Doing the Opposite! on: October 01, 2012, 03:33:51 pm
MAX4213, EL5050 for you to start with and you will need 1 for every video output. http://www.maximintegrated.com/ have lots of good info about designing what you want to do in the product video section http://www.maximintegrated.com/products/video/ and also try google for video distribution amplifiers (VDA).
32  Using Arduino / Programming Questions / Re: Bitshift help. on: October 01, 2012, 03:07:31 pm
I have managed to create the following test sketch to simulate my real program and try to implement the gear shit indicator led flash. The timings have been slowed down for easier reading in the serial monitor.
Code:
byte temp;
byte Display_RPM;
byte ShiftIndicator = 5;
unsigned long result = 6902;

long previousMillis = 0;

byte flash(long Interval)
{
  long currentMillis = millis();
  if(currentMillis - previousMillis > Interval)
  {
    previousMillis = currentMillis;
    return 1;
  }
  else
  {
    return 0;
  }
}

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  temp = result/1000;
  Display_RPM = ~((1 << (8 - temp)) -1);
  if(temp >= ShiftIndicator && flash(1000) == 1)
  {
    bitSet(Display_RPM, 0);
    Serial.println(Display_RPM, BIN);
  }
  else
  {
    Serial.println(Display_RPM, BIN);
  }
  delay(900);
}
Is there a better way todo this or is this ok? The useful thing is that i can use the flash routine for other things too.
33  Using Arduino / Programming Questions / Re: Bitshift help. on: October 01, 2012, 12:49:04 pm
Ok cheers. Is bit set good to use here or keep using the << stuff? Am just trying to work out a routine now.
34  Using Arduino / Programming Questions / Re: Bitshift help. on: October 01, 2012, 02:01:18 am
Ok thanks alot. So i have 2 options of code to use

1 - the lookup table
or
2 - the bitshift function

is one better then the other or just personal preference? I will be using the i2c driver for my display and this RPM stuff is just the start of it. I now need to find out the best way to flash the last "on" LED in 11111000 if a variable has been set to 5 or if the variable has been set to 6 flash the last "on" LED in 11111100.
35  Using Arduino / Programming Questions / Re: Bitshift help. on: September 30, 2012, 04:13:21 pm
Quote
Code:
  b = 1 << 1 | 1;
use instead:


Code:
  b = (b << 1) | 1;
to produce 0b00000001 -> 0b00000011 -> 0b00000111 ...

or

Code:
  b = (b >> 1) | 0x80;
to produce 0b10000000 -> 0b11000000 -> 0b11100000 ...;

This is also considerably faster.
dhenry, i have tested what you have said and it doen't work.
36  Using Arduino / Programming Questions / Re: Bitshift help. on: September 30, 2012, 03:38:43 pm
I have just tested that and yes it does work, great. What is the -1 doing in this if you don't mind me asking (i have not used these functions before so this is new to me)? If am going to use it i need to know what it is doing lol but thanks a bunch to WizenedEE and Grumpy_Mike.
37  Using Arduino / Programming Questions / Re: Bitshift help. on: September 30, 2012, 03:19:26 pm
Yes Grumpy_Mike but for example if result was 4 then i need that code to create 11110000.
38  Using Arduino / Programming Questions / Re: Bitshift help. on: September 30, 2012, 02:20:34 pm
Thank you, you have been most helpfull and i understand now.
Quote
I'm almost certain there is a better way to do this than using a loop or a lookup table though.
If anyone knows then that would be great.
39  Using Arduino / Programming Questions / Re: Bitshift help. on: September 30, 2012, 01:18:03 pm
Thank you, could please explain what this is doing b = b | (1 << i); because i cant get my head around it and if i had a value of 6 i would get 111111 but do i need to add 2 0's at the end to make up the full 8 bits like 11111100? Also is this a good way to do what am trying to do or would using a array like this be a better way ?
Code:
byte ArrayRPM[8] =
{
  B00000000,
  B10000000,
  B11000000,
  B11100000,
  B11110000,
  B11111000,
  B11111100,
  B11111110,
  B11111111,
};
40  Using Arduino / Programming Questions / Bitshift help. on: September 30, 2012, 12:01:19 pm
Hello all,

Code:
//Main.
void loop()
{
  byte b = 0;
  unsigned long temp = 0;
  unsigned long result = 0;
  char str[32];
  
  Ignition_State_Check();
  
  get_PID(ERPM, &result, str);
  temp = result/1000;
  for(byte i = 0; i < temp; i++)
  {
    b = 1 << 1 | 1;
  }
  Serial.print(b, BIN);
  delay(1000);
}

Am a bit stuck for ideas and not sure if am trying to do this correctly. I have a value in unsigned long result then that gets divided by 1000 to give me either a 0 or a 1 or a 2 or a 3 or a 4 or a 5 or a 6 or a 7 or a 8 depending whats in unsigned long temp. I then am trying to use a for loop to give me for example in byte b 00111111. This will then be used to light up 6 out of 8 LED's but i ony get is 00000010. Can anyone tell me what am doing wrong?

Thanks.
41  Using Arduino / Programming Questions / Re: Control Two LED's with one button on: September 27, 2012, 03:51:12 pm
Have a look at the statechangedetection example that comes with the Arduino software. With a few little changes this can be done very easily.
42  Using Arduino / Programming Questions / Re: STRING To HEX Converter on: September 19, 2012, 02:45:38 pm
Quote
No, strtoul() doesn't put anything into any sort of string. It parses an unsigned long integer from a string.

I know it doen't. I was just saying thats how i use it and that it's easy to use.
43  Using Arduino / Programming Questions / Re: STRING To HEX Converter on: September 19, 2012, 01:13:07 pm
I use strtoul(). It puts my ASCII sting into a unsigned long HEX string that i can use for anything and is only one line of code.
44  Using Arduino / LEDs and Multiplexing / Re: LED driver ic. What devices do you all use? on: September 19, 2012, 12:52:47 am
Thanks I will have a look. SMD soldering is my job so that's not a problem lol. The chip I was looking at can also be used as i/o expander but is optimised for LEDs with brightness control.
45  Using Arduino / LEDs and Multiplexing / Re: LED driver ic. What devices do you all use? on: September 18, 2012, 03:50:23 pm
Thanks. Av been looking at this http://uk.farnell.com/on-semiconductor/cat9532wi-t1/led-driver-16bit-program-24soic/dp/1656134 that looks interesting and a ok price.
Pages: 1 2 [3] 4 5 ... 9