Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 289
61  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 11, 2014, 06:29:59 am
3) I can send data from Arduino to Xbee#2 connected to laptop. The voltage at pin DOUT (pin 2) of Xbee#1 (connected to Arduino) is around 4.8V. Is it ok?

Not OK. XBee is a 3.3V device and is not 5V tolerant. How is it being powered? Not sure how the DOUT pin could be that high if it's connected to an input pin on the Arduino unless the XBee is being powered by more than 3.3V.
62  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 10, 2014, 03:35:53 pm
This generally means measuring the period between two consecutive pulses. For example at 1Hz I have a 1Hz refresh rate, but as the frequency increases so does my refresh rate. Technically speaking anything with less than 10 samples a second is useless and I aim at having about 100 samples per second.

Understood, but "generally" is a bit fuzzy. With a 1Hz input, we can't do 10 samples/second. At lower frequencies, I assume it must be OK to just do the best we can, i.e. time one cycle. At the other end of the spec (2048Hz) timing one cycle will generate a lot more than 100 samples/sec. So there's another requirement here for the sampling frequency, has that been codified? If 100 SPS is OK at 2048Hz, the code could sample 20 cycles of the input. Or it could sample one cycle, report that, and skip 19 cycles. Maybe the sampling interval is always 100ms except at input frequencies below 100Hz, then it's one cycle. So a hybrid approach. Sounds now like this is not a frequency counter at all, i.e. it doesn't count cycles, but it measures the period and reports the inverse (frequency). Still looks like a frequency counter on the outside but the measurement technique is different.

I'm not writing code yet, still trying to understand the requirements smiley-wink
63  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 10, 2014, 12:33:31 pm
@casemod, no worries, I know what you mean. Sometimes things do get frustrating, and sometimes on both ends of the stick.

Anyhoo, here is a frequency counter library I did and here is an example sketch. It uses an external 1 Hz signal for the time base which happened to come from a GPS but could just as easily be an RTC. For that matter, I suppose it could be from another timer configured to generate an interrupt at 1 Hz. Don't think Timer2 can run that slow, but it could generate 125 Hz interrupts, which I think could be made to work.

Have a look, does it meet your requirements?
64  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 10, 2014, 08:55:57 am
The original goal is to measure a frequency ranging from 1 to 2048Hz in steps of 1Hz.

In order to achieve such precision the minimum sampling period must be 2048 cycles, therefore as time between each consecutive pulse doubles I need to count a total of 2048^2 = 4194304 pulses per second.

Excellent, that is the problem statement that we were looking for. I would not have guessed that to be the goal from all the conversation thus far.

There are several frequency counter sketches around, I assume you've looked into them?
65  Using Arduino / Project Guidance / Re: reading 1000ths of a seconds from a pcf8583 rtc on: August 10, 2014, 06:55:19 am
-the timing system shall display the time down to at least the hundredth of a second (xxx.xx) to 2
decimal points
- the timing system shall be accurate to within 3ms over 60 seconds (50 ppm)
- the timing system shall provide the same timing for both lanes to within 2ms over 60 seconds

Good, this describes both the accuracy and the resolution needed. But, the 3rd point is redundant and somewhat conflicting. The 2nd point says accurate to 3ms, the 3rd point says 2ms. Not exactly sure what the words "shall provide" mean, especially given the requirement to display to 0.01 second.

I am aware of several RTCs with 0.01 sec resolution but none that provide 0.001. Since time of day is not needed, as pointed out above, one solution would be a custom Arduino-compatible board with a decent crystal, say 20ppm. I've designed and built several of these and they do indeed run within spec. Then one of the internal timers could be set up to give interrupts at 1000Hz, which would provide the time base. Use the external interrupts for the start and stop for each lane.

If a custom board isn't an option, then an external oscillator with the required accuracy will be needed, as an Arduino's ceramic resonator isn't good enough. This most likely will not be an RTC; while many can provide various frequency square waves, the frequencies are usually powers of two. (Although I suppose computational games could be played to come close enough, similar to the way millis() works.)
66  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 10, 2014, 06:30:23 am

Forget timers, forget clocks, just explain what you actually want to achieve at
a high level - there may be better ways to achieve what you want.

Reply #9 has a detailed explanation regarding the problem

Reply #9 has somewhat of an explanation of the current solution, which evidently leaves something to be desired. Explain the original goal, not the problem with the current implementation. In fact, leave details of the current implementation out completely.
67  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 09, 2014, 08:15:20 pm
Given the formula, the prescaler has nothing to do with that. The counter value has to be multiplied by 256 when using Timer 2, and by 65536 when using Timer 1.

Yes.
68  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 09, 2014, 07:51:07 pm
Sorry, just not seeing the big picture here.

Timer2 is 8 bits, yes? Wouldn't the overflow multiplier therefore be 256, instead of 65536?
69  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 09, 2014, 07:24:21 pm
By definition the timer is synchronous with the system clock. What we have is a phase delay, caused by the processing needed to handle the interrupt. However, this should be perfectly determinate, so perhaps the problem is not one of synchronicity but rather the time lag is the issue?

It is indeed.

But Think about this:
An event is generated on an external pin, so an interrupt is called. By the time the interrupt saves TCNT2 and clears it a few clock cycles have passed and this time is lost as the timer restarts from 0.

Sure this could be avoid with input capture, but only timer one has this feature and it is already being used.

Indeed, but without some answers to the questions I asked as to the requirements, we're at a bit of a loss.
70  Using Arduino / Project Guidance / Re: reading 1000ths of a seconds from a pcf8583 rtc on: August 09, 2014, 07:22:29 pm
The problem is that the stock Arduino Uno uses a ceramic resonator instead of a crystal. The best resonator tolerance on Mouser is 0.1%, which is 1000 ppm. A good crystal, on the other hand, will have a few tens of ppm accuracy tolerance.

My recommendation would be to make a barebones Arduino on a breadboard with a crystal instead of a ceramic resonator if you really need accuracy. Then you can use millis() and it will be much more accurate.

All true but if an external RTC is used then its accuracy is the critical factor.  And most will be a few tens of ppm or the ones with TCXOs will be maybe an order of magnitude better.

OP also needs to define "accurate" ... 1000 ppm, 100 ppm, 50 ppm, 10 ppm, or something else?
71  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 09, 2014, 07:15:03 pm
By definition the timer is synchronous with the system clock. What we have is a phase delay, caused by the processing needed to handle the interrupt. However, this should be perfectly determinate, so perhaps the problem is not one of synchronicity but rather the time lag is the issue?
72  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 09, 2014, 07:12:15 pm
What is the nature of the pulse? What is its frequency or period? Does it vary? Within what range? How is "pulse not detected" defined, when a certain amount of time elapses? How much time?
73  Using Arduino / Project Guidance / Re: reading 1000ths of a seconds from a pcf8583 rtc on: August 09, 2014, 06:53:01 pm
The chip has a register for hundredths of a second (datasheet, p8), so it certainly ought to be possible.

If there isn't a library that addresses it, modify an existing library or write a new one. If you really meant thousandths of a second as in the subject line, I'd say you're out of luck.
74  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without on: August 09, 2014, 06:45:53 pm
Now the issue I am facing is that i need to keep the counter synchronous to the clock frequency and some clock cycles are lost while reseting TCNT2.

Which clock? The MCU system clock? The pulse that's being detected? I don't understand this requirement, the first two sentences seem a good solution to the problem.
75  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 08, 2014, 10:16:44 pm
Thank you Jack.

I tried two Xbees connected to laptop using two Xbee Explorers + X-CTU. They worked well. That's why it was so confusing when they did not work when I added Arduino.

OK, good. Sounds like a code problem then.

Quote
BTW, please correct me if I am wrong. I though in a network, one Xbee should be Coordinator and the other should be End Device. Is it wrong?

Well, that is one of two ways XBee 802.15.4 modules (f.k.a. Series 1) can be configured. There is also a peer-to-peer configuration and I believe that is the way they come from the factory. I also think most of the discussion I've seen here on the forum is for peer-to-peer. If you don't have the product manual, download a copy.

XBee ZB modules (f.k.a Series 2) OTOH require one coordinator in every network. The rest of the network can consist of routers and/or end devices.

I would assume that the XBee 802.15.4 modules configured as coordinator/end device operate somewhat differently than the XBee ZB modules. How much different they are I cannot say. My experience is primarily with the XBee ZB modules, so I can't comment much more on the XBee 802.15.4 modules and especially when they are configured as coordinator/end device.

So let's have a look at the the code. How about reposting it just so we know we are looking at the latest code. Put the code between code tags (#), not quote tags. See http://forum.arduino.cc/index.php/topic,148850.msg1118324.html#post_codetags
Pages: 1 ... 3 4 [5] 6 7 ... 289