Writing code for battery operated projects


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Steve

    Here is the schematics, I finally got it finished. While I was drawing the schematics it occurred to me that I could get rid of the transistor that outputs to pin 23 by pulling the pin low (instead of high) with the resistor and then just tie the TX's +5V output directly to that pin. I have all the unused pins set as inputs, should I be tying all the unused pins to negative with the 10k resistors or would it make any difference?

    While I was trying different wiring schemes to turn on/off the lcd, I ended up frying my Lcd ...... oops! I was switching both the positive and negative for the Lcd off with transistors, I still can't figure out what I did wrong to fry the Lcd. I thought I'd wait to see what you could suggest as to how I have the Lcd wired before I start playing around with a new one and end up frying it too! There must be something wrong with the way I have the Lcd wired because even If I disconnect both the positive and negative for the lcd the milliamp draw is still .38 to .48 milliamps while the micro is in a sleep loop. I also noticed that when I disconnect the negative to the Lcd (pin 1) the Lcd still works good? When I disconnect all 10 wires to the Lcd then the milliamp draw drops to .007 to .122 ma which is much better, so I'm thinking that it must be wired incorrectly but I can't see what I've done wrong. Any help will be very much appreciated.

    Thanks jessey
    Attached Images Attached Images  

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    What i suggest, have an i/o wich will cut/apply power to all external devices. Use a transistor/mosfet/realy to do it. OR since i/o can drive/sink 25ma, you can use some of them to do the job as well. 1 for LCD(VDD and contrast line), 1 for CMOS circuit, Pull-up resistors and so on for all the other things. Before go to SLEEP, set all i/o to input. By doing that, all supply will be remove to external devices.

    Once you'll get out of SLEEP, just reset TRIS to normal state, add a little safety sake pause for the LCD start-up, Reset LCD flags FLAGS=0 and you're in business.

    Quote Originally Posted by jessey
    should I be tying all the unused pins to negative with the 10k resistors or would it make any difference?
    it's up to you.
    Quote Originally Posted by jessey
    I also noticed that when I disconnect the negative to the Lcd (pin 1) the Lcd still works good?
    that's possible, he take his ground from XYZ pins, contrast, data,r/w or else.

    Some suggestions
    • For the pin 23, you can also just use a resistor in serie with VCC
    • remove the relay and use only two diode. both cathode together as the VDD output, one anode to regulator, the other to the Battery. Cheaper, smaller and works!!!

    hope this help.

    Small reading from Microchip about power saving
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Steve

    Thanks a million!

    With your helpful suggestions I finally got the consumption down to .009 milliamp draw in my sleep loop. I had a few problems that I still don't understand. It is working good though but at first when I implemented you changes I was still getting .4 to .5 milliamp draw.

    Here is what I did:

    I am now using pin 20 to turn on the Lcd's VDD and the contrast's +5V by having it set as an output and forcing it high to turn them on, then to shut them off I did as you suggested and set the TRIS to an input for pin 20 and that works great for that part. I also did the same thing with pin 21 and connected the negative for both the Lcd and the contrast to that pin and that works great too. I'll use the same procedure for all the other external circuits later as well.

    I also moved the R/W of the Lcd to RE2 and added Low PORTE.2 before my goto mainloop statement. Then just before going to sleep I shut off the VDD and the contrast's +5V and the grounds then set all the TRIS for all the Lcd pins as inputs but was still getting .4 to .5 milliamp draw on my amp meter in sleep.

    I checked all the Lcd pins with a digital logic probe and found that the DB4, R/W, the Lcd's VDD and the +5V & -5V for the contrast were all high. When I disconnected DB4 then all those pins that were high went low and the milliamp draw started to fluctuating from .009 to about .107 milliamps which I was pretty excited to see!

    In my sleep loop, I'm monitoring a push button so I have the option of turning on the Lcd while in sleep and that's when the milliamp draw jumps to .107 but it's only there for a very few milliseconds. That's great, using a photo sensor to keep the program in the sleep loop when it's dark and using a motion detector to silence the buzzer when no one is around to hear it should make the batteries last for 6 months or so. That's great!! Would you have any suggestions on a voice chip that would good for battery operation?

    The problem was, that I was getting a high on pin 27, seems that setting the TRIS works on all the other Lcd pins on PORTD except for RD4 for some reason? I tried forcing RD4 low using PORTD.4 = 0 when I shut off the Lcd and it's working great now.

    Any ideas on what's happening there?

    Thanks jessey

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    for some voice module... winbond do some chip that allow you to record your own message. I'd use ISD4002 few times and they work great. Not cheap but easy to use and you don't need any external/third party programmer to use them. There's probably a tons of other but this is the only one i'd work with.

    I think they also do some Text-To-Speech module to. have a look to their Website
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default Can anyone help me?

    Hello, My program is functioning good now for the better part, the milliamp draw is down considerably which is great. Thanks again Steve! Now I need a kick start to: figuring out a way to set up a variable (if it's at all possible?) that I can use in an IF...Then statement to sound an alarm when the battery voltage (that powers the pic) drops to the level that the user can set using push buttons to change that variable. I did hear that there are voltage regulators that have a low voltage alarm built in so that's an option too.

    For now I'm using a 5K pot connected to an ADC input in a 10 bit mode to simulate the batteries output voltage. Later I'll set up a voltage divider for the batteries and tap it off to the adc input. The code below that I'm using seems to be functioning as expected thanks to the PBP Archives.

    The_Battery_Voltage = (The_Battery_Voltage */ 500)>>2
    LCDOut $fe, 1,"DC Volts = ",DEC (The_Battery_Voltage/100),".", DEC2 _
    The_Battery_Voltage

    With the above code my 5K pot adjusts from 0.00 to 4.99 volts which as far as I can figure so far, should be good. I did a print to another screen without the math to show The_Battery_Voltage variable and it showed 1023 while the one with the math above was printing 4.99.

    Would anyone know the math involved to create a word variable to accomplish this? Another option I have is to use another adc input using a 5K pot and use that variable in my IF...Then but I would like to go with push buttons. Any help would be greatly appreciated.

    Thanks jessey

  6. #6
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Smile Volt Read

    KK:
    gosub GetVolt
    SerOut LCDScreen, N2400, [LCDCmd, LCDLine1,"T= c"," V=",#LCDVHigh,".",#LCDVLow]
    goto KK

    GetVolt:
    'For global reference to system voltage, use the Voltage variable, which is based on a
    'scale of 1 to 1000, with 775 = 7.75 volts. Remember that the resistors on the board
    'divide the actual battery voltage in half so the ADC can "digest" it without damage.
    'ADCIN voltages are limited to 5. Voltage are compared with the onboard
    'precision voltage reference which delivers a perfect 5V.


    '**Voltage**
    LCDVLow=0
    LCDVHigh=0
    Voltage=0
    ADCIN VoltChannel, Voltage 'Take just 1 voltage sample. 7.6V = 194
    Voltage = Voltage * 4 '194 * 4 = 776
    LCDVHigh = Voltage / 100 '776 / 100 rounds to 7
    LCDVLow = (Voltage // 100) / 10 '776 // 100 = 76, 76 / 10 = 7
    'Final Display = 7.7

    return
    Last edited by jetpr; - 13th June 2005 at 18:12.

  7. #7
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Question

    Just a thought !
    When using the ACIN command for A/D conversion
    How is this turned off before going to sleep ?
    Does pbp automatically take care of it


    Isaac

Similar Threads

  1. Writing good/proper code
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 00:55
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts