Hi,
I am looking for help form any body who is good with arduino, I have tried to add support to the TX software, for a rotary encoder, HRPG AS16#51c, which uses channel A, channel B, GND and 5v. I have modified a TX board using a 6 pin RJ11 socket taking a 5v and D10 feed from the expansion port, I know this mod is ok because I have compiled and uploaded a sketch for encoder which works fine on its own. Sketch used is attached.
I then tried to incorporate this sketch into the TXv1.4 ISTest b001 software which after a lot of head scratching I thought I had done, It compiled and uploaded seemingly ok. But when I used serial monitor and turned the vane all I got was " N", in which ever position I turned the vane to.
The pins I am trying to use D10 and 5v from the expansion port and A3 and GND from what would have been the original wind socket. I am wondering if the problem it has something to do with the way pins are configured in the software, especially A3.
Sketch _may24a is the sketch for rotary encoder which works fine on its on.
WeatherDuino tx v1.4 is where I have tried to implement the above sketch which compiles and uploads ok but does not give compass bearings except "N",
Please have a look and let me know what you think,
Thanks
regards
tyntop
PS, also attached datasheet for encoder
I'm far from be "good with arduino", anyway I will try to help, mostly as an incentive to your efforts...
As you haven't posted the encoder library, I don't know if the sketch with the changes I did, compiles without errors.
The changes I did, are based on the assumption that the sketch "Sketch _may24a" is working.
Hi caneira,
Please find enclosed the encoder library.
Regards
tyntop
I have updated the sketch in post #2
I tried the updated sketch, which compiled and uploaded, I then used the serial monitor, but when the vane was turned, the wind direction did not change and correspond to the new position. As said in the first post, when just using the May24 sketch it works perfectly.
I have found a local group which meets weekly, where some off the members have done some programming and they seem to be of the opinion, that there may be a problem due to interrupts (ie not enough of them ) could this be so ?
It is so frustrating, I feel that I am close to getting this mod working but due to my lack of programming knowledge it will take a lot longer, So if any body can help, then it will be appreciated.
Caniera has helped a lot, and I thank him for that, but he is busy with the further development of the weatherduino system.
Regards
tyntop
tyntop, in fact and according to the info I read on some of the sketch examples, to read the encoder with readability, you must use at least one pin with interrupts capability. Arduino Nano have two, and both are already used by the WeatherDuino Pro2 TX software, one for the wind speed and the other for the rain gauge.
The rotary encoder library, includes an sketch example, that can be used to read the encoder when it is connected to pins without interrupt capabilities. You, correctly tried to use that code, but as is stated on the comments, using this method you can only track very slow motion, and it also requires that you loop through the read procedure very quickly, which not happen when the code was inserted in the TX code. I think this is why, you can read it with your May24 sketch code.
Quote:// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Maybe there are some solutions, but keep in mind that dealing with interrupts requires advanced knowledge of the specific microcontroller, and most of those technics are far ahead of my own knowledge.
Don't give up in your intention. Take a breadboard, put a Nano on it, and continue with your experiments, you don't lose nothing, by the contrary you win knowledge.
Try your sketch (May24) changing the encoder pins between pins with interrupt capability and other without that capability, certainly you will find a great difference.
Arduino nano pins 2 (interrupt 0) and 3 (interrupt 1) have interrupt capability.
tyntop, anyway you can try this new code. I doubt it works, but who knows !
Even if it reads anything from the rotary encoder, it will be no good for a live use.
Hi,
Sorry, I can't help with the coding, but to avoid going down a "dead end":
How do you propose to keep the vane set and "calibrated" to North? However good the hardware and software may be, there is always the risk that one or more pulses may be "dropped" (over a period of weeks, months or years) and then the "reference" direction will be lost.
AFAIK all normal direction "encoders" use a multi-channel (4+) "Gray Code" wheel, or of course the established potentioneter (Davis), multiple magnetic reed switch (Fine Offset) or Phase Delay (linked to the anemometer rotation) methods.
Cheers, Alan.
Hi,
Thanks for the replies so far on this topic.
From what I can understand My idea for using encoders wont work due to the lack of interrupts.
Is that right ?
I remember reading the Atmel 328 Data sheet and it mentioned that besides there being EXTERNAL interrupts, of which I believe there are 2 which at present are being used by the wind speed and rain gauge sensors, there are also INTERNAL interrupts, up to 20 if not more (23).
So I went to the Arduino web site and did a search "PCINT" which I believe are the INTERNAL interrupts.
Attached is what found about them, I am thinking if these can be used it would be a big help not only for my project, but for the WeatherDuino project as well.
I look forward to your opinions.
Regards
Tyntop
Tyntop, the main reason why, I think that a rotary encoder is not suitable for the task you are trying to do can be deducted on the AllyCat post.
This is also the reason I wrote above:
"Even if it reads anything from the rotary encoder, it will be no good for a live use. "
Sorry, I can't give more help in this matter.