Announcement

Collapse
No announcement yet.

VDI-RODERICO

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    VDI LED v1.2

    Originally posted by roderico View Post
    I compiled a new version removing the trigger delay for quicker response, reported by Artyom. I had to add a pull-up resistor of 10K between MCLR pin and Vdd because it added some noise to the A/D when turning off a led (even being disabled in the configuration). I also added up to 4 leds (perkun's idea), so you only need to replace the firmware (and/or some leds) to change between different versions.

    2 led firmware:

    D1 on for -60 < vdi < 0
    D2 on for 0 <= vdi < 90
    D1 and D2 on -> op-amp in saturation and alternating on/off for calibration
    D3 and D4 not used (no need to be in the pcb)

    4 led firmware:

    D1 on for -60 < vdi < 0
    D2 on for 0 <= vdi < 20
    D3 on for 20 <= vdi < 45
    D4 on for 45 <= vdi < 90
    D1 and D2 on -> op-amp in saturation and alternating on/off for calibration

    I tested both with a PIC16F88 but it should work with PIC12F683/675. In the attached files there is also an example pcb layout that could be used for this vdi:
    I got some PIC12Fxxx's and made a small test. Unfortunately, they didn't work as expected (like the PIC16F88 ). The channels X and Y were swapped in the schematics but not in the firmware and PIC12F683 A/D converter was not working properly. I fixed these issues and compiled a new version which worked well in the tests I did (attached below).

    For PIC12F675 you need to take care of not to erase the internal oscillator calibration data, there should be an option in your programmer, or answer no to overwrite the data at the time of programming. You can also write down the calibration value before writing the firmware in case you accidentally erase it (it is in the address 0x3FFF and should start with 0x34).
    Attached Files

    Comment


    • #32
      Hi!
      Who has used PIC16F876 instead?
      I have some spare...

      Is the hex file already ready for this micro using LCD?

      Comment


      • #33
        Originally posted by Sacchetti View Post
        Hi!
        Who has used PIC16F876 instead?
        I have some spare...

        Is the hex file already ready for this micro using LCD?
        Hi, current hex files won't work for this model, for each model you need to recompile the source code after defining the pins, adapting the A/D converter code, etc. and in this case, you would also need an external 4MHz oscillator if timings are not changed in the code for different oscillator frequency...

        Comment


        • #34
          Originally posted by roderico View Post
          Hi, current hex files won't work for this model, for each model you need to recompile the source code after defining the pins, adapting the A/D converter code, etc. and in this case, you would also need an external 4MHz oscillator if timings are not changed in the code for different oscillator frequency...
          Hi Roderico,
          thank you.

          I know the necessity to add a Xtal (I have a lot of 4MHz) plus 2 little caps or directly an hibrid oscillator because the '876 doesn't have internal Osc.

          I haven't problems to change the software for this micro but I can not do it immediately.

          Which problem do you encountered with the A/D code?
          The resolution is the same, can be the register usage will be different therefore as soon as possible I will read the datasheets of both pic to compare them.

          Comment


          • #35
            Originally posted by Sacchetti View Post
            Hi Roderico,
            thank you.

            I know the necessity to add a Xtal (I have a lot of 4MHz) plus 2 little caps or directly an hibrid oscillator because the '876 doesn't have internal Osc.

            I haven't problems to change the software for this micro but I can not do it immediately.

            Which problem do you encountered with the A/D code?
            The resolution is the same, can be the register usage will be different therefore as soon as possible I will read the datasheets of both pic to compare them.
            Hi Sacchetti, PIC16F876 will work fine, the code will only need to be adapted and recompiled, it is not difficult, I can help with that. There is no problem with the ADC, as you mentioned the registers need to be adapted for this model. To adapt the code, first you need the circuit schematics, e.g. X -> RA0, Y-> RA1, battery meter could also go in RA3, then LCD can be connected to RB4-RB7, switches SW1-3 to RB0-2 which have internal pull-ups and the crystal to pins 9 and 10, if you could post the complete schematics would be very good, I can modify the code and recompile it for you to test it...

            Comment


            • #36
              Originally posted by Sacchetti View Post
              Hi Roderico,
              thank you.

              I know the necessity to add a Xtal (I have a lot of 4MHz) plus 2 little caps or directly an hibrid oscillator because the '876 doesn't have internal Osc.

              I haven't problems to change the software for this micro but I can not do it immediately.

              Which problem do you encountered with the A/D code?
              The resolution is the same, can be the register usage will be different therefore as soon as possible I will read the datasheets of both pic to compare them.
              Hi again, I adapted and recompiled the code using this pin configuration:

              Analog inputs:

              X -> RA0
              Y -> RA1
              BAT -> RA3

              Switches:

              SW1 -> RB3
              SW2 -> RB2
              SW3 -> RB1

              LCD:

              RS -> RC7
              RW -> GND
              EN -> RC6
              DB0-3 -> GND
              DB4 -> RB4
              DB5 -> RB5
              DB6 -> RB6
              DB7 -> RB7

              The attached file contains an unoptimized firmware only for testing, If I'm not mistaken it should work. It would be good if you could post the schematics for debugging using the above connections...
              Attached Files

              Comment


              • #37
                Originally posted by roderico View Post
                Hi again, I adapted and recompiled the code using this pin configuration:

                Analog inputs:

                X -> RA0
                Y -> RA1
                BAT -> RA3

                Switches:

                SW1 -> RB3
                SW2 -> RB2
                SW3 -> RB1

                LCD:

                RS -> RC7
                RW -> GND
                EN -> RC6
                DB0-3 -> GND
                DB4 -> RB4
                DB5 -> RB5
                DB6 -> RB6
                DB7 -> RB7

                The attached file contains an unoptimized firmware only for testing, If I'm not mistaken it should work. It would be good if you could post the schematics for debugging using the above connections...
                To test it I need the opamp, I can try to use another one because I haven't it that in schematic.
                I am going to prepare a schematic as you request. Please wait.

                Comment


                • #38
                  Originally posted by roderico View Post
                  Hi again, I adapted and recompiled the code using this pin configuration:

                  Analog inputs:

                  X -> RA0
                  Y -> RA1
                  BAT -> RA3

                  Switches:

                  SW1 -> RB3
                  SW2 -> RB2
                  SW3 -> RB1

                  LCD:

                  RS -> RC7
                  RW -> GND
                  EN -> RC6
                  DB0-3 -> GND
                  DB4 -> RB4
                  DB5 -> RB5
                  DB6 -> RB6
                  DB7 -> RB7

                  The attached file contains an unoptimized firmware only for testing, If I'm not mistaken it should work. It would be good if you could post the schematics for debugging using the above connections...
                  The attached file contains the new schematic. Please check it.

                  About R12 it must be calculated. It depends from which LCD you are using.
                  Read the datasheet and search for Vled and Iled of backlight.
                  Having a 3,2V and 40mA then the value is 220ohm but it is better to use 270ohm to limit current.
                  Some display for example has 4,2V and 35ma then the value is the same but it is important to check always the datasheet.
                  To beginners: the formula is R = (Vbat - Vled) / Iled, W = (Vbat - Vled) * Iled
                  Example:
                  R=(12V-4,2)/0,035=229 but we will use a bigger value (270ohm) because the battery when is full charged is more of 12V.
                  W=0,273 but we use double power (0,5W) or more. For experience it is better to use 1W here.

                  About the ratio R9/R10 it divide by 3 the voltage (15 / 3 = 5V).
                  Sorry, I haven't read the source code therefore I don't know if it is correct.
                  With a 12V battery full charged there are 14,4V then I have calculated this ratio to get 15V as "end of scale".
                  In this way there is the maximum precision reading the battery voltage but can be there is to modify the software.

                  VDI.pdf

                  Comment


                  • #39
                    Originally posted by roderico View Post
                    Hi again, I adapted and recompiled the code using this pin configuration:

                    Analog inputs:

                    X -> RA0
                    Y -> RA1
                    BAT -> RA3

                    Switches:

                    SW1 -> RB3
                    SW2 -> RB2
                    SW3 -> RB1

                    LCD:

                    RS -> RC7
                    RW -> GND
                    EN -> RC6
                    DB0-3 -> GND
                    DB4 -> RB4
                    DB5 -> RB5
                    DB6 -> RB6
                    DB7 -> RB7

                    The attached file contains an unoptimized firmware only for testing, If I'm not mistaken it should work. It would be good if you could post the schematics for debugging using the above connections...
                    Hi Roderico!
                    Please, check also this attached schematic!
                    Please, can you add backlight control in the software? Thank you.
                    Obviously, it is only for who has good battery...

                    "Backlight -> RB0"
                    VDI_BL.pdf

                    Comment


                    • #40
                      Sorry, I have done all too fast, there was some mistakes.

                      These are the "issue 1" schematics:
                      VDI.pdf
                      VDI_BL.pdf
                      I think they are correct, please check them.

                      The following instead are wrong therefore don't use them:
                      Attached Files

                      Comment


                      • #41
                        Originally posted by Sacchetti View Post
                        Sorry, I have done all too fast, there was some mistakes. These are the "issue 1" schematics: [ATTACH]39816[/ATTACH] [ATTACH]39817[/ATTACH] I think they are correct, please check them. The following instead are wrong therefore don't use them:
                        Hi Sacchetti, to me it looks fine and would match the test firmware, however I would connect DB0-3 to GND and add a pull-up resistor to pin 1 (MCLR) -- 10K -- Vdd. The battery meter is just a voltage divider, if you are changing the resistor's value you might also add a 5.1V diode to protect the pic in case you make a mistake. If I'm not mistaken, using 10K for R10 would scale [12V-9V] to [4V,3V] while using R10 = 6K8 you'll have [3V,2.28V] the difference is small but safer and it is not required too much precision here, in any case you might be able to adjust the scaling factor in the menu without changing the code when using 10K. Although you save a pin connecting 12V directly to the voltage regulator would it be better than going from 8V to 5V? In any case with your current schematics the test firmware might work so please give it a try and then it can be fixed if it does not work. For the BL I might need to see but for the other pics there is no much space left...

                        Comment


                        • #42
                          Originally posted by Sacchetti View Post
                          The attached file contains the new schematic. Please check it.

                          About R12 it must be calculated. It depends from which LCD you are using.
                          Read the datasheet and search for Vled and Iled of backlight.
                          Having a 3,2V and 40mA then the value is 220ohm but it is better to use 270ohm to limit current.
                          Some display for example has 4,2V and 35ma then the value is the same but it is important to check always the datasheet.
                          To beginners: the formula is R = (Vbat - Vled) / Iled, W = (Vbat - Vled) * Iled
                          Example:
                          R=(12V-4,2)/0,035=229 but we will use a bigger value (270ohm) because the battery when is full charged is more of 12V.
                          W=0,273 but we use double power (0,5W) or more. For experience it is better to use 1W here.

                          About the ratio R9/R10 it divide by 3 the voltage (15 / 3 = 5V).
                          Sorry, I haven't read the source code therefore I don't know if it is correct.
                          With a 12V battery full charged there are 14,4V then I have calculated this ratio to get 15V as "end of scale".
                          In this way there is the maximum precision reading the battery voltage but can be there is to modify the software.

                          [ATTACH]39812[/ATTACH]
                          In my case, I'm using a generic 1602 display, similar to this:
                          https://www.openhacks.com/uploadspro...one-1602a1.pdf
                          and for the backlight it is only required +5V and usually the recommended resistor is given, anyway I'm not using the backlight...

                          Comment


                          • #43
                            Originally posted by roderico View Post
                            Hi Sacchetti, to me it looks fine and would match the test firmware, however I would connect DB0-3 to GND and add a pull-up resistor to pin 1 (MCLR) -- 10K -- Vdd. The battery meter is just a voltage divider, if you are changing the resistor's value you might also add a 5.1V diode to protect the pic in case you make a mistake. If I'm not mistaken, using 10K for R10 would scale [12V-9V] to [4V,3V] while using R10 = 6K8 you'll have [3V,2.28V] the difference is small but safer and it is not required too much precision here, in any case you might be able to adjust the scaling factor in the menu without changing the code when using 10K. Although you save a pin connecting 12V directly to the voltage regulator would it be better than going from 8V to 5V? In any case with your current schematics the test firmware might work so please give it a try and then it can be fixed if it does not work. For the BL I might need to see but for the other pics there is no much space left...
                            Hi Roderico!
                            About the "4 bit bus mode" the data line DB0-3 are not used.

                            I have seen you are using an MCP1703 and an LCD without backlight.
                            I think that both choices was done to reduce current consumption.
                            But if your objective is to reduce the consumption to the minimum then you cann't connect DB0-3 to GND because you increase it.

                            Every line source current and in a quantity that depends from technology used to build the chip.
                            In many chinese datasheet this information is not present, however sometime it is present.
                            As soon as I found one then I add this one in this thread to show you.
                            However, I have found some chip to do -1uA for every line and some chip do -250uA or -500uA.
                            You can check this using a good (fine) multimeter in the lower mA scale and connecting every pin to GND.
                            At the end, for example, in the worst condition you have by useless -500uA x 4 = -2mA of consumption more!

                            Comment


                            • #44
                              Originally posted by roderico View Post
                              Hi Sacchetti, to me it looks fine and would match the test firmware, however I would connect DB0-3 to GND and add a pull-up resistor to pin 1 (MCLR) -- 10K -- Vdd. The battery meter is just a voltage divider, if you are changing the resistor's value you might also add a 5.1V diode to protect the pic in case you make a mistake. If I'm not mistaken, using 10K for R10 would scale [12V-9V] to [4V,3V] while using R10 = 6K8 you'll have [3V,2.28V] the difference is small but safer and it is not required too much precision here, in any case you might be able to adjust the scaling factor in the menu without changing the code when using 10K. Although you save a pin connecting 12V directly to the voltage regulator would it be better than going from 8V to 5V? In any case with your current schematics the test firmware might work so please give it a try and then it can be fixed if it does not work. For the BL I might need to see but for the other pics there is no much space left...
                              Hi Roderico!
                              About the pull-up resistor on MCLR, please read datasheet on page 124.
                              It is better you download it directly from microchip to be sure we are reading the same and the last.
                              You are right if the micro is configured for use POR, but I prefer to use PWRT or OST.
                              In this case PWRT is enough for example.
                              Doing in this way there isn't necessity to add the resistor.
                              Therefore I am going to check the source code release 1.3 for 16F88 and 16F690 to see how is configured.

                              Comment


                              • #45
                                Originally posted by roderico View Post
                                Hi Sacchetti, to me it looks fine and would match the test firmware, however I would connect DB0-3 to GND and add a pull-up resistor to pin 1 (MCLR) -- 10K -- Vdd. The battery meter is just a voltage divider, if you are changing the resistor's value you might also add a 5.1V diode to protect the pic in case you make a mistake. If I'm not mistaken, using 10K for R10 would scale [12V-9V] to [4V,3V] while using R10 = 6K8 you'll have [3V,2.28V] the difference is small but safer and it is not required too much precision here, in any case you might be able to adjust the scaling factor in the menu without changing the code when using 10K. Although you save a pin connecting 12V directly to the voltage regulator would it be better than going from 8V to 5V? In any case with your current schematics the test firmware might work so please give it a try and then it can be fixed if it does not work. For the BL I might need to see but for the other pics there is no much space left...
                                Hi Roderico!
                                I am looking the source code to understand how it is used the ADC and you are right!

                                In this case the Vref is 5V and the end of scale using 20K/6K8 ratio is 19,4V.
                                You have found this value in the file "mcu.h".
                                This is the line:
                                uint8_t g_adc_bat_scale = 0xC2;
                                Therefore there calculating 19.4/26800*6800 we have about 4,922V.
                                Using the code V1.3 there isn't modification to do using a battery voltage up to 19,4V and 20K/6K8 as R1/R2.

                                But if we would obtain an end of scale of 20V then we must change the line in this way:
                                uint8_t g_adc_bat_scale = 0xC8;
                                Therefore there calculating 20.0/40000*10000 we have 5V.
                                Then we can use my schematic with 30K/10K as R9/R10.
                                This solution reduce the flow current in R9/R10 (they are R1/R2 in your schematic).
                                The 30K resistor exist as E24 (5%) while as E96 (1%) we can found 30K1 but it is the same.

                                Using 20K/10K the end of scale can be regulated to 15V but it is too low.
                                Instead having 19,4V or 20V both end of scale are without the risk to damage the input pin, using a 12V battery.
                                Therefore I have changed the value of R9 to 30K in my schematic but I prefer wait to publish it.
                                I would like to test all before.

                                You wrote:
                                "Although you save a pin connecting 12V directly to the voltage regulator would it be better than going from 8V to 5V?"
                                Sorry, please can you explain better?

                                I am trying to recompile the code with the microchip C 8 bit compiler.
                                Do you have used the free, the 60 days license, do you have bought the license or do you have used ... something else?

                                Comment

                                Working...
                                X