1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

HT12D and HT12E encoder/decoder issues

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by MrDEB, Dec 4, 2012.

  1. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    The HLVD module will only monitor Vdd. The HLVD reference pin sets a level to compare Vdd against. It is not an input to the HLVD module.

    This has been mentioned before and hasn't changed.
     
    Last edited: Feb 14, 2013
  2. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I was referring to the externally generated trip point as pictured in the data sheet. Then just compare the Vdd which is 5v (this is a regulated voltage) against the unregulated voltage generated by the voltage divider. Have yet to try this out but reading the data sheet it looks pretty straight forward. Set the HLVDIN =%1111
    After I try this out I will let you know how well it works. I only need this external reference on the Matrix board since I am using 4.8v on the TX board now that I determined I can fit the NiMH batteries into the desired enclosure by going diagonally.At least that's what it looks like after I drew up in SKETCHUP the enclosure and batteries. Will wait for sample to be sure.
    LOTS to check on and test further. Even contemplated running the two boards with the TX board automatically transmitting to the MATRIX board "switch closures" done in code and see just how long the unit runs. If I had more experience using the Usart I could get an accurate time base on battery voltage etc. Might be a hard way to get experience but won't know until I try.
     
  3. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    I had already considered using the HLVD reference connected to a voltage divider to compare against Vdd when I wrote the Digital-DIY article. When the voltage divider output is LESS than Vdd, the battery is low. Sounds doable except for one slight detail. The MAXIMUM level allowed on any PIC pin, including the HLVD module reference input, is Vdd + 0.3 volts. This doesn't provide enough headroom between a charged battery and a low battery. Slick idea if it would work but it can't.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22

    I connected it up and dosn't make much difference between setting bit 7 or not. Thinking of adding a pot to adjust the external reference voltage
    this is from the data sheet
    Got to be able to do something with this? iots in the data sheet and they never lie --lol
    I need to detect when the battery drops below 4.5volts or better yet drops below 6v. 5Volts the display quits working somewhere around 4.5 volts.
    If I configure the voltage divider to output the proper voltage without going over 5v but can go lower than 5v by adjusting the pot then maybe it might work??
    Will ponder on this but right now got to take the wife out to dinner.
     
  6. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    possible solution??
    lower the Vdd voltage to 3v using an adjustable voltage reg then use the external trip point but then I am exceeding the Vdd + 0.3 volts
    got to be a way to accomplish this as the data sheet make reference to users flexibility.
     
  7. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    What? It doesn't make any difference? Insert several expletives here. It damned well does make a difference.

    Do you think I just make this stuff up?

    Consider a battery of 10.6 volts when fully charged for easy math. Make a 2:1 voltage divider using two equal resistors, and connect the tap of the divider to the HLVD reference input. The HLVD reference input will see 5.3 volts which is the maximum allowable if the PIC is powered at 5.0 volts via a regulator.

    As the battery discharges, the voltage divider tap will fall to 5.0 volts and the HLVD module will trip. What is the battery voltage at this point? 10 volts - the battery voltage is still on the high end of the curve, nowhere near dead. This isn't going to work.

    When the HLVD external reference = Vdd, the HLVD module will trip. Because the HLVD input can't go above Vdd + 0.3 volts, there's not enough range for a battery test this way. The HLVD level can't be adjusted (in the PIC) when an external input is used, The only comparison is to Vdd.

    Like I said, I thought this through when I wrote the HLVD module article at Digital-DIY. IT WON'T WORK.

    Why am I too stupid to learn that this is a waste of time and effort? At least it's providing entertainment for others.
     
  8. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    He could use a divider if it was a prefect world but its not a prefect world. the battery would change over time and mess up the readings.
     
  9. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I guess the data sheet is full of hot air as I suspected.
    " This gives users flexibility because it
    allows them to configure the High/Low-Voltage Detect
    interrupt to occur at any voltage in the valid operating
    range."
    I set the bit 7 and led lit up. disabled bit 7 and led still lit up. Should work only one way?
    Going to recheck my readings in the morning
    This is what I was referring to about no difference.
    I am basically agreing with you. The external HLVD is kind of full of hot air?? It dosen't work? or at lest I hav'nt found out how to configure it to work for the external HLVD trip point.
     
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    Well Mrdeb how can we help you didn't post any thing that we could look at and help you.
    p.s. like your hlvd settings
     
  11. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    found this

    it says pin 7 (HLVD input) is to be connected to the Vdd via a voltage divider. Sounds like going back to square one? unless I am missing something?
    http://www.picbasic.co.uk/forum/con...-use-the-HLVD-module-as-a-low-voltage-monitor
    Am rethinking this HLVD for detecting the battery status and contemplating just using a voltage divider connected to say portA.0 and use the ADC feature. Have a button press to apply the battery voltage to the port.
    Using the same HLVD code that Jon posted over at DDIY etc.
    As Jon pointed out you can't input Vdd + 0.3 volts to the HLVD pin.
     
  12. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    The HLVD module works exactly as intended...to monitor Vdd against an internal setpoint or using an external voltage input. The HLVD input is intended as an external setpoint, not to monitor an external voltage. Sorry this does not conform to MrDeeb's understanding or desire but it does exactly what's intended.

    No, no no, NO! The HLVD code has absolutely nothing to do with reading an ADC pin. Why would it?

    What the datasheet says is:

    Allows the user TO SUPPLY THE TRIP VOLTAGE.....this is the reference voltage, not the voltage to be measured.

    I won't even bother with the rest of the errors in the last couple messages. Suffice it to say, the HLVD module is for monitoring Vdd supplied to the chip, nothing else.
     
  13. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    This was also pretty clearly spelled out in my article Using the HLVD Module in Swordfish Basic.

     
  14. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    YES I went down the wrong path thinking I could monitor the battery condition using the HLVD.
    On the bright side I can use the ADC feature and a tri-color LED and now I have a BATTERY FUEL GAUGE.
    This will work out better in the end anyway.
    PLAN= using the usart to count time and display amount of time at each voltage step then I can determine within reason how long and what voltage the GREEN led is on etc.
    If I am correct then this will work.
     
  15. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    Terminology counts. Monitoring battery voltage does not give you a battery fuel gage. A battery fuel gage monitors current flow in to and out of the battery. It's an extremely accurate way of determining battery charge state. It's much more involved than monitoring battery voltage.

    The HLVD module monitors Vdd; for a chip powered directly from a battery, this is battery condition.

    Yes, getting actual battery data is a good and necessary idea as long as you are aware this this info is valid for a particular battery chemistry for a battery of a certain capacity under a certain load condition. Even changing brands of battery will make a difference.
     
  16. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I just need/want a ballpark figure.
    In the middle of configuring the UART. keep getting weird symbols etc on screen. Changing baud rate and looking at why my code fails. Going for the simple HELLO WORLD first then on to monitoring the pic
     
  17. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    uart has lots of ???????????????????

    This should work. I tried changing the baud rate, being careful that both code and uart are same but keep getting ?????????????
    The echo works but ?? Can't believe I am going backwards. And yes the led blinks.
    Code (text):
    Device = 18F2420
    Clock = 20
     
    // external xtal
    Config OSC = HS
    // import usart and conversion modules...
    Include "usart.bas"

    dim led as porta.0

    SetBaudrate(br9600)
    While true
    led=1
    delayms(1000)
    toggle(led)
    USART.Write("Hello World",13,10)
    DelayMS(1000)

    Wend
     
     
  18. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    Found issue
    Programmed a different board and it worked with internal osc so tried on main board and now it works.
    I need to figure out why the osc setting won't work as planned?
     
  19. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    This kind of error means the following:

    1. Baud rate is wrong

    2. Parity and stop bits are wrong

    Or

    3. Clock specification is wrong (which results in incorrect baud rate)


    You didn't really "find the issue" - you threw out the hardware and started over.


    Chances are the clock rate specified doesn't match the crystal installed. How do you know if the clock frequency is correctly specified? Set up an LED to flash 1 second on and one second off and check the time against a stop watch. Better still, time 5 flashes on and see if the result is 10 seconds. If it's off by a measurable amount, check the crystal frequency and verify no PLL multipliers are enabled.

    How many times have you read these same suggestions? And how many times have you ignored them? Hint: any answer less than 100% is not accurate.
     
  20. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I had an led blinking as suggested numerous times. Need to investigate why it now runs with internal oscillator. I tried different baud rates as well. I presently have it working but want to investigate why the difference as a learning lesson.
    Going to compare what was working and what wasn't working.
     
  21. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    To verify the clock speed, the LED test has to be done AT THE SAME TIME and THE TIME ACCURATELY MEASURED.

    It's not the fact that the LED flashes that's significant. What is significant is that the actual flash time and the programmed flash time are the same.

    I still don't believe you understand that the micro doesn't have a clue what one second is. It only knows that it's so many clock cycles based on the clock speed you've told it. If the clock speed isn't correctly specified, everything time-related, including baud rate, will be in error.

    Sorry to sound harsh or angry, but these are simple concepts and they've been explained over and over again yet you fail to grasp them or to understand that they apply to this project, your last project, your first project and everyone in between. If you don't understand the simple stuff, you're clueless on how to proceed when things don't work.
     

Share This Page