CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Reading wind speed with an AAG Weather Station

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
D-Kens
Guest







Reading wind speed with an AAG Weather Station
PostPosted: Wed Apr 27, 2005 3:41 am     Reply with quote

Hi...

I'm connecting a PICC 16F877 to a TAI8515 weather station and trying to collect all measures. Seems I managed to get the wind direction and the temperature, but I have more than slight doubts about the wind speed (according to my last measures, the wind blew at 150mph this morning). Laughing

I won't ask you to have a look at my code, but I'd like to know if someone here already worked on such a project.

The idea is to count rotations of a sensor with a DS2423 and to calculate the speed, knowing the length of one rotation and the time. I use an interrupt on Timer2 to check the time between 2 counts, and a formula provided by AAg Electronica, which is :

V(mph) = 2,453*V(rotations/sec)

I'm not even sure their formula is right, but I have to trust 'em... Crying or Very sad Anyway, to avoid 32 bits operations on the counter (DS2423 counts on 4 bytes), I want to reset the counter each time I read it, and the only way I found to do so is to set the data line low for some seconds, to reset the component.

Sorry, seems I have several points in that part of my code that can explain the error, and I dunno where to look first. If someone had this kind of problem before, that could help !!! Wink
Ttelmah
Guest







PostPosted: Wed Apr 27, 2005 4:36 am     Reply with quote

Why use the DS2423?. The 877, has a pair of CTC modules, which can do the counting for you in the main processor.
Having said that, I wouldn't try to reset the counter. Just read the two low bytes into an int16, and subtract the last from current. Assuming you use unsigned numbers and arithmetic, the way the maths 'wraps', you should still get the correct result (assuming the total 'count' is allways below 65536). So if (for instance), the last count was FFF8, and the chip counts 100 pulses, the new reading will be 005C, and 005C-FFF8 will give 0064 (100 Smile ).
Are you sure the sensor gives one pulse/rev?. The formula works in 'rotations', but if (for instance), the sensor gives 128pulses/rev, then it would explain the values you are seeing. Also, remember that in some European countries, ',' is the decimal seperator, not the 'thousands' indicator. If so, your formula might be out by a factor of 1000*. Personally, for speed, assuming the factor is '2.453', I'd create a union, containing a 32bit value, and an array of four bytes, put the incoming count into the 32bit value, multiply by 628, and then take the value in the second byte as the 'speed'. For one count, this will give '2', while for ten counts, you will get 24 etc.. The effective multiplication factor, will be 2.453125, and will be much quicker (and smaller), than using any form of FP arithmetic.

Best Wishes
D-Kens
Guest







PostPosted: Wed Apr 27, 2005 5:49 am     Reply with quote

Ok, thanks for your answer. Razz

Why use DS2423 ?! Well, if it was up to me, I wouldn't use it, but that's the component available in the weather station, and that's the one my boss wants to use then : we're supposed to just "read" datas from the weather station, not compute them by ourselves.

One thing I wonder with that component is what I really read when accessing the counters. Seems you can't latch the values, so I assume the counter is still changing (as the wind keeps blowing) while I'm reading the 2 low bytes : what's the reliability of my reading then ?

Anyway, yet I'll try not to reset the component, as you suggested, and just ignore the 2 most significant bytes (yeah, the final "count" is always under 65536, else the wind would blow VERY VERY fast Wink ). Even if it doesn't solve my problem, I would find that solution much more pleasant than the other one...

Last point : the sensor gives 2 pulses per revolution, as it's composed of two reed switches that close and open while rotating, but I have it in mind when working with the formula, don't worry. Smile

Okey, going back to fighting that sensor !!!
Wish me luck...
D-Kens
Guest







PostPosted: Wed Apr 27, 2005 5:50 am     Reply with quote

Ok, thanks for your answer. Razz

Why use DS2423 ?! Well, if it was up to me, I wouldn't use it, but that's the component available in the weather station, and that's the one my boss wants to use then : we're supposed to just "read" datas from the weather station, not compute them by ourselves.

One thing I wonder with that component is what I really read when accessing the counters. Seems you can't latch the values, so I assume the counter is still changing (as the wind keeps blowing) while I'm reading the 2 low bytes : what's the reliability of my reading then ?

Anyway, yet I'll try not to reset the component, as you suggested, and just ignore the 2 most significant bytes (yeah, the final "count" is always under 65536, else the wind would blow VERY VERY fast Wink ). Even if it doesn't solve my problem, I would find that solution much more pleasant than the other one...

Last point : the sensor gives 2 pulses per revolution, as it's composed of two reed switches that close and open while rotating, but I have it in mind when working with the formula, don't worry. Smile

Okey, going back to fighting that sensor !!!
Wish me luck...
Ttelmah
Guest







PostPosted: Wed Apr 27, 2005 9:42 am     Reply with quote

I think you will find that the counter value is latched at the start of the transfer. You would read all four bytes (since this is the only 'read' available for them), but just discard the high bytes, so you can use 16bit arithmetic.
Good Luck!...

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group