Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I am using a pic16F88 and I amnot sure whcih pins to use. Right now I am using pins 1, 2, 17, 18 for my lcd out and also pin 6,7 for control. Pin 5 and 14 for powering. Pin 8 for input.
    If I use the Vref, then i need to move my lcd out pins to pin 10 through 13 ( I wanted to us these for led out, piezo and other outputs i needed. I never had luck outputting on port A. Shouln't be hard to get it going.
    Also I dont have any MCP1525, I only have 7805 chips maybe use this chip for now and replace it when I get another ?...
    and use a voltage divider on the 7805 to obtain 2.5 v ?
    I assume the MCP1525 is an LDO chip ??

    also instead of using 40k and 10 K resistors, can I use 400k and 100K ? would that take up even less power ?
    Well, if you can't change the Vref pins around, then maybe use 2 A/D converters and compare your fixed reference against the total applied? In other words, if you're battery ever got down to 2.5v, then the A/D input would be at maximum. Just takes a bit of math I supose...

    And since you don't have any MCP1525 or anything like it, I know one thing you do have that does have a fixed reference...

    Or do you?
    I'll give you a little bit to think about it, then I'll give you the answer.

    And also since you don't have a fixed voltage (or do you? )...you won't need to worry about the resistors for now.

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the only fix voltage I have now is my Lm7805 at 5v.

    and also, what is the lowest voltage for 4 Nmhi batteries, (when needed to be changed)

    well I removed the Lm7805, , i dont have any fox voltage reference. also, leaving the LM7805 there, i could not get enough voltage for the unit to operate
    Last edited by lerameur; - 1st January 2007 at 17:00.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    the only fix voltage I have now is my Lm7805 at 5v.

    and also, what is the lowest voltage for 4 Nmhi batteries, (when needed to be changed)

    well I removed the Lm7805, , i dont have any fox voltage reference. also, leaving the LM7805 there, i could not get enough voltage for the unit to operate
    Read the datasheets for the 7805 and you'll find out why you can't get enough voltage from them, they need a couple of volts of overhead to operate correctly.

    Lowest volts for NiMH batts - really depends on the current draw, the higher the draw, the higher the end voltage. I suspect for your application, you might want to charge them up when they hit 1v/cell (4v total). That will give you some time to get to it. I wouldn't let them get much below .8v/cell, but then they're on their way out anyways. As far as charging, take them up to about 1.4v/cell depending on the charge rate, faster charge, higher voltage (up to a point of course), slower charge, lower voltage. Overall, 1.4v is a good round number.

    More on the easy voltage reference later. Here's a bit of a teaser for you: take a diode, any old diode, a resistor and a 9v battery. Hook it up as follows, +9v to resistor, resistor to one side of diode, other side (banded side) of diode to -9v. Read the voltage across the diode, just the diode and only the diode. Now change the value of the resistor, read the voltage across the diode again, change the resistor again, read the diode again, swap the 9v battery for the 4cell NiMH pack, read the diode again. Let me know your results.

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes actually, i went and read that , its like a diode, loosing 0.7 volt, so you need a bit more to compensate..
    i have been working on the a/d conversion, again this is my first time, I am reading section 12 of he pic16f88 datasheet.

    i wrote this program , bit it do not display the right inotmation:


    'RECEIVE PIC
    INCLUDE "modedefs.bas"
    DEFINE OSC 20 'use external 20mhz crystal
    CMCON = 7
    ANSEL = %00001100 'Put port 2 and 3 analog and otehr digital
    ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %00010001 ' Configure and turn on A/D Module

    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 0 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000

    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    input1 var word : input2 var word

    TRISA = %11111111 ' Set PORTA to all input

    Pause 500

    loop: ADCIN portA.2, input1
    ADCIN portA.3, input2

    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value1: ", DEC input1 ' Display the decimal value
    lcdout $FE,$C0, "Value2: ", dec input2
    Pause 200

    Goto loop
    End

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yes actually, i went and read that , its like a diode, loosing 0.7 volt, so you need a bit more to compensate..
    i have been working on the a/d conversion, again this is my first time, I am reading section 12 of he pic16f88 datasheet.

    i wrote this program , bit it do not display the right inotmation:


    'RECEIVE PIC
    INCLUDE "modedefs.bas"
    DEFINE OSC 20 'use external 20mhz crystal
    CMCON = 7
    ANSEL = %00001100 'Put port 2 and 3 analog and otehr digital
    ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %00010001 ' Configure and turn on A/D Module

    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 0 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000

    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    input1 var word : input2 var word

    TRISA = %11111111 ' Set PORTA to all input

    Pause 500

    loop: ADCIN portA.2, input1
    ADCIN portA.3, input2

    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value1: ", DEC input1 ' Display the decimal value
    lcdout $FE,$C0, "Value2: ", dec input2
    Pause 200

    Goto loop
    End
    What did it display? How are you hooked up?

    The thing I had in mind is keeping Vref+ and Vref- on Vdd and Vss (battery power). One A/D input is connected to the diode, .7v, which should always stay the same (give or take a bit depending on temperature). The output number from the A/D will be a ratio of that diode (.7v) to the battery voltage., the lower the number, the higher the battery voltage.

    For example, if the battery voltage was actually .7v (just for arguments sake, I know it would never be that low), and the diode voltage was .7v, the A/D output would be 1023.
    If the battery voltage was 4.8v and the diode was .7, .7 divided by 4.8 multiplied by 1024 (full scale A/D reading) would be 149 (149.3). So, 149 would be full charge.
    Taking that same train of thought, if the battery voltage was 3.6v (.9v/cell, battery dead), .7 divided by 3.6 multplied 1024 would be 199 (199.1) which would mean dead battery.

    Are ya following me here?

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    More on the easy voltage reference later. Here's a bit of a teaser for you: take a diode, any old diode, a resistor and a 9v battery. Hook it up as follows, +9v to resistor, resistor to one side of diode, other side (banded side) of diode to -9v. Read the voltage across the diode, just the diode and only the diode. Now change the value of the resistor, read the voltage across the diode again, change the resistor again, read the diode again, swap the 9v battery for the 4cell NiMH pack, read the diode again. Let me know your results.[/QUOTE]

    I will do this test a little bit later, i will give you the results.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    More on the easy voltage reference later. Here's a bit of a teaser for you: take a diode, any old diode, a resistor and a 9v battery. Hook it up as follows, +9v to resistor, resistor to one side of diode, other side (banded side) of diode to -9v. Read the voltage across the diode, just the diode and only the diode. Now change the value of the resistor, read the voltage across the diode again, change the resistor again, read the diode again, swap the 9v battery for the 4cell NiMH pack, read the diode again. Let me know your results.
    I will do this test a little bit later, i will give you the results.[/QUOTE]



    Ok, it looks like you're ahead of me a bit

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well the program i wrote was initially suppose to be a simple a/d program. I never did A/D, so i wanted to write a program with just that in it, I want to read a sensor (light to voltage ) then output the value to the lcd screen, Then I will integrate this concept into my project. I am using the pic16F88,with analog input on portA.2 and A.3.
    My lcd shows about 100 at start up and goes up gradually to 980 in about a minute. obviously something is wrong
    I want to understand the A/D by that knowing how to program , before going further.
    k
    Last edited by lerameur; - 2nd January 2007 at 02:59.

  9. #9
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    another thing, I get (sometimes) wired values on the receiver. I read the temperature good, but once in a whjile, I get 2 temperature reading on one line, other ime i get +200, etc...
    does this have to do with the system being wireless, or the fact that my encoding technique is weak and prone to mistakes??

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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