Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out (and rewrite) the ADC (Analog to Digital Converter) to monitor battery voltage. Document the other ADC inputs so we can use them. #22

Open
mcolinj opened this issue Nov 10, 2020 · 2 comments
Assignees

Comments

@mcolinj
Copy link
Contributor

mcolinj commented Nov 10, 2020

Server/ADC.py is an interface to an analog to digital converter. See if you can figure out what it is wired to, and what things can be read from the robot. The raspberry pi does not have any analog pins that it can read. It has to use the I2C bus to read analog values determined my another chip.

I know that it is used to implement the POWER command.

In Server/server.py, there is this code:

`

elif cmd.CMD_POWER in data:

                    ADC_Power=self.adc.recvADC(2)*3

                    try:

                        self.send(cmd.CMD_POWER+'#'+str(ADC_Power)+'\n')

                    except:

                        pass

`
You could look in the client code and see what it does with it. (maybe just displays it?)

It could be accessing the voltage reading of the battery, which would be very useful.

Note: You can also look at the Freenove documentation to see if it explains the POWER command output.

See if you can figure out if there are other ADC channels we could use to read some other analog values
on the robot.

@mcolinj
Copy link
Contributor Author

mcolinj commented Nov 10, 2020

Actually, it does look like it might read battery voltage (I'm wondering what other channels might be able to read?)

In Server/server.py, there is this function. See if you can figure out what it does (and when).

`
def Power(self):

    while True:

        ADC_Power=self.adc.recvADC(2)*3

        time.sleep(3)

        if ADC_Power < 6.8:

          for i in range(4):

                self.buzzer.run('1')

                time.sleep(0.1)

                self.buzzer.run('0')

                time.sleep(0.1)

        elif ADC_Power< 7:

            for i in range(2):

                self.buzzer.run('1')

                time.sleep(0.1)

                self.buzzer.run('0')

                time.sleep(0.1)

        else:

            self.buzzer.run('0')

`

@mcolinj mcolinj changed the title Figure out what the ADC (Analog to Digital Converter) is used for with the POWER command Figure out (and rewrite) the ADC (Analog to Digital Converter) to monitor battery voltage. Document the other ADC inputs so we can use them. Nov 10, 2020
@mcolinj
Copy link
Contributor Author

mcolinj commented Nov 10, 2020

Note that the wpilib interface to an analog electrical value is called AnalogInput

see: https://github.com/robotpy/robotpy-wpilib/blob/2019/wpilib/wpilib/analoginput.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants