Loading...
  Show Posts
Pages: [1] 2 3 ... 62
1  Using Arduino / Programming Questions / Re: latest cruise control program review request on: May 24, 2013, 10:35:43 pm
and this is silly:
Code:
    int ButtonModeEnabled = 1;
    if (ButtonModeEnabled == 1)
ButtonModeEnabled can't be anything but 1 when the "if" statement is executed, so the "if" is redundant.

Pete
2  Using Arduino / Storage / Re: Reading from SD(CSV file) by using if - Need your help on: May 24, 2013, 06:29:08 pm
I'm not familiar with parseInt but your example of data has 6 integers per line. Your code reads 10. Change your code so that it only reads S1, S2 , ... S6.

Pete
3  Using Arduino / Programming Questions / Re: Onewire temperature sensor, just getting "no more addresses"? on: May 24, 2013, 06:14:19 pm
I agree with Rob. I tried your code and it finds all 4 ds18b20 on my OneWire bus. Check your wiring.

Pete
4  Using Arduino / Project Guidance / Re: Arduino Clock + DS3234 on: May 24, 2013, 04:07:55 pm
Yup, it should work as long as they don't share chip select pins but I'd be more comfortable moving the MAX72xx off the SPI bus altogether since it isn't an SPI device. And to be safe, the 3234 chip select should be pin 10 and move the MAX72 chip select somewhere else.

Pete
5  Topics / Science and Measurement / Re: RTC Stopwatch on: May 24, 2013, 03:58:55 pm
A minor fix:
Code:
seconds = ((60 + elap_seconds) - init_seconds) % 60;
That is equivalent to:
Code:
seconds = (elap_seconds - init_seconds) % 60;

The same type of thing applies to the minutes and hours.

Pete
6  Using Arduino / Project Guidance / Re: Arduino Clock + DS3234 on: May 24, 2013, 03:45:08 pm
The DS3234 is SPI and although my mods to your code only access it once every 24 hours (I hope), you have set up the MAX7219 to use pin 10 but this is the chip select for the SPI device. That is going to be bouncing up and down 100 times a second which will drive the RTC nuts. If possible, you must move the LED device off the SPI bus pins (10, 11, 12, 13).

Pete
7  Using Arduino / Project Guidance / Re: Arduino Clock + DS3234 on: May 24, 2013, 10:31:18 am
Quote
but is updating the display every second
My mistake, I put "tick_flag = 1" after the first "if". It should be before that so that it is set on every entry to ISR.
Also make sure that you have done this:
Code:
volatile int hSecond=0; // these are our time variables 
volatile int seconds=0;
volatile int minutes=0;
volatile int hours=0;

I don't know if you can send updates to the display at 100/sec. If not, you could try reducing the amount of data that needs changing. For example, every "tick" changes hSeconds but 99 of the 100 "ticks" do not result in a change of the seconds, minutes or hours. And 59 out of 60 updates of the seconds won't change the minutes or hours. For each of the seconds, minutes and hours, add another variable that holds the last value that was displayed. If the new value is the same as the old, don't try to update that one.

Pete
8  Using Arduino / Project Guidance / Re: Arduino Clock + DS3234 on: May 23, 2013, 08:54:04 pm
You shouldn't be doing any I/O in the ISR. The I/O should be done in loop() and the ISR should signal when it wants the led updated or the RTC read.
You must also declare any variable used by the ISR to be volatile as I have done for the two flag variables in the code below.
Try this (untested) code:
Code:
volatile unsigned char tick_flag = 0;
volatile unsigned char day_flag = 0;
ISR(TIMER1_COMPA_vect)  // This code executes at each interrupt of Timer1
{
  hSecond++;

  if (hSecond < 100) return;
  seconds++;
  hSecond = 0;
  // signal loop that the led should be updated
  tick_flag = 1;
  if (seconds < 60) return;
  minutes++;
  seconds = 0;
  if (minutes < 60) return;
  hours++;
  minutes = 0;
  if (hours == 24) {
    day_flag = 1;
    hours = 0;
  }   
}

void loop()
{
  if(tick_flag) {
    led_print(hours, 6);  // Print the hour
    led_print(minutes, 4);  // Print the minutes
    led_print(seconds, 2);  // Print the seconds
    led_print(hSecond, 0); //Print the hundreths of seconds
    tick_flag = 0;
  }
  if(day_flag) {
    SPI.begin();
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE3); // both mode 1 & 3 should work RTC_init();
    ReadTimeDate();
    clearSPI();
    day_flag = 0;
  }
}

Pete
9  Using Arduino / Interfacing w/ Software on the Computer / Re: Serially confused on: May 23, 2013, 04:11:36 pm
Code:
  while (Serial.available() > 0) {
This only guarantees you that that there is at least one character ready to be read, but inside the while loop you read two characters.

Pete
10  Using Arduino / Storage / Re: Swapping between two SD files on: May 23, 2013, 02:24:37 pm
Quote
1st line shown here is my error
When I was at uni, I failed Clairvoyance 101 very badly so I have no idea what that error message was and the code fragment that you've allowed us to see is not sufficient to know what is wrong anyway.

Pete
11  Using Arduino / Programming Questions / Re: Does this look right. on: May 23, 2013, 02:16:53 pm
When you attach an interrupt, interrupt zero is on Arduino Pin 2, interrupt one is on pin 3.
So, a statement like this:
Code:
attachInterrupt(0, rtc_interrupt,FALLING);
will be using an interrupt generated by the signal on pin 2. To use that pin the code will presumably do something like this:
Code:
pinMode(BUTTONR,INPUT);
digitalWrite(BUTTONR,HIGH); // to set the internal pullup

Pete
12  Using Arduino / Programming Questions / Re: Longitude and Latitude to UTM on: May 23, 2013, 02:10:44 pm
The subject says you want to convert Lat/Long to UTM but then you say you've been trying to convert code which calculates the distance between two lat/long coordinates. You need to explain more clearly what it is you actually want to do.

Quote
I will have to use long and latt coordinates, which appear to have NO numerical, (to meters), significance.
What does that mean?

Pete
13  Using Arduino / Programming Questions / Re: Someone to double check my first code,plz on: May 23, 2013, 09:55:07 am
(a) does it compile?
(b) does it work?

If yes to both of the above then you're good to go.

Pete
14  Using Arduino / Interfacing w/ Software on the Computer / Re: Serially confused on: May 22, 2013, 10:22:30 pm
Read this: How to post code properly

Pete
15  Using Arduino / General Electronics / Re: 1st read of DS18S20 temp sensor is wrong on: May 19, 2013, 05:30:42 pm
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
The important word in the comment is start. You aren't giving the device time to finish the conversion so the first time through you get rubbish.
If you have the resolution set to 12 bits (I think that's the default), it takes 750 milliseconds to do the conversion. I give it 800 just to be sure:
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(800);

Pete
Pages: [1] 2 3 ... 62