Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    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??

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    HI I did the test , as I suspected, I get 0.7v all the time. So I caould put a few in a row to get a higher voltage difference and use that as a reference voltage.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    HI I did the test , as I suspected, I get 0.7v all the time. So I caould put a few in a row to get a higher voltage difference and use that as a reference voltage.
    You could, but those diodes will vary in voltage with time, temperature, current flow, moon phases, etc, not by much, but they will change over time and temperature at least, and in series, they'd do nothing but get worse. Therefore, you're battery voltage reading will change accordingly, and probably screw you up in the long run. And you have to have X amount of current to even get the diodes to conduct. You might end up using more power than you would really want to just to get a reading.

    Have you been able to get the A/D working yet?
    Like I said, spare pin to a resistor (probably 1K or so), other side of resistor to non-banded side of diode, banded side of diode to ground. Tap the non-banded side to your A/D port and take some readings with the battery hooked up as normal and A/D converter set up with Vref+ at Vdd and Vref- at Vss. If you're using the 10bit A/D, you should get a reading arorund 150-ish. Then as the battery wears down, the reading will go up. A reading of roughly 200 will mean a dead battery.

    And, you can save the power to read the battery by change that 'spare pin' mentioned above to an input and shutting off the A/D module.

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok , I have a problem now:

    i wrote this program below, I configured so it read porta.0, but I get 0 output when I ground it and oscillation between 890 and to 900 when i put it to Vdd.
    if I leave the program as is, and just put the input wire to portA.1 theni get 0 output when i groud the wire, and 1023 when I put it to Vdd.
    Why am I getting a better result to a non configured port 6, at least i am ot calling this pin ??
    my ADCON0 = %10000001 i believe this is for An0 to input
    I am also trying to get two input for A/d , is that possible ?

    'RECEIVE PIC
    INCLUDE "modedefs.bas"


    DEFINE OSC 20 'use external 20mhz crystal
    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
    CMCON = 7
    ANSEL = %00001100
    ADCON1 = %10000010
    ADCON0 = %10000001

    Pause 500

    loop: ADCIN porta.0, input1

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

    Goto loop
    End


    Also, what do you mean by : Spare pin to resistor ?
    Last edited by lerameur; - 3rd January 2007 at 01:32.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    trying to get multiple input,but getting wrong values


    loop:
    ADCON0 = %10000001 ' Configure and turn on A/D Module
    ADCIN porta.0, input1
    pause 50

    ADCON0 = %10001001 ' Configure and turn on A/D Module
    ADCIN porta.1, input2
    pause 50

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

    Goto loop

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok , I have a problem now:

    i wrote this program below, I configured so it read porta.0, but I get 0 output when I ground it and oscillation between 890 and to 900 when i put it to Vdd.
    if I leave the program as is, and just put the input wire to portA.1 theni get 0 output when i groud the wire, and 1023 when I put it to Vdd.
    Why am I getting a better result to a non configured port 6, at least i am ot calling this pin ??
    my ADCON0 = %10000001 i believe this is for An0 to input
    I am also trying to get two input for A/d , is that possible ?

    'RECEIVE PIC
    INCLUDE "modedefs.bas"


    DEFINE OSC 20 'use external 20mhz crystal
    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
    CMCON = 7
    ANSEL = %00001100
    ADCON1 = %10000010
    ADCON0 = %10000001

    Pause 500

    loop: ADCIN porta.0, input1

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

    Goto loop
    End


    Also, what do you mean by : Spare pin to resistor ?


    Oscillation - I get that too on most everything I do on the A/D inputs (I don't know if it's a function of crappy circuit boards or bad design, doesn't matter to me anyways). You're probably going to want to do some sort of software averaging and/or put a capacitor across the input line to smooth it out a bit.

    Spare pin on resistor - instead of putting the diode direct to battery power, thru a resistor to ground, you can intermittently power that diode thru a spare PIC output pin and save that power. Every little bit helps ya know.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok, but what about this loop here, can i do that, having multiple a/d conversion on one chip ?

    loop:
    ADCON0 = %10000001 ' Configure and turn on A/D Module
    ADCIN porta.0, input1
    pause 50

    ADCON0 = %10001001 ' Configure and turn on A/D Module
    ADCIN porta.1, input2
    pause 50

    From the definition of ADCON0, I can only choose one pin for A/D conversion. Maybe thats why it get mixed up .
    Last edited by lerameur; - 3rd January 2007 at 21:39.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok, but what about this loop here, can i do that, having multiple a/d conversion on one chip ?

    loop:
    ADCON0 = %10000001 ' Configure and turn on A/D Module
    ADCIN porta.0, input1
    pause 50

    ADCON0 = %10001001 ' Configure and turn on A/D Module
    ADCIN porta.1, input2
    pause 50

    From the definition of ADCON0, I can only choose one pin for A/D conversion. Maybe thats why it get mixed up .
    You can do A/D on more than one pin, just not at the same time. I'm not sure why it didn't work for you in the one post. Maybe not waiting long enough between conversions and/or long enough between switching A/D channel assignment. I think you have to wait awhile, not only after the last conversion, but after you switch the channel, which ADCIN does for you. So, again, not sure. I'll think on it. Until then, double check your configuration, TRIS assignments, ADCON setup, etc.etc.
    And you shouldn't have to use more than one channel for your project, unless I missed something there too...

Similar Threads

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