Programming an AnalogInput

My team is currently using the BOSCH APC-2 winch motor and we’ve wired it to the robot like so:
RoboRIO Analog #1 -> Red wire -> (33 + 33 + 33 + 33 +33 +33) OHM Resistor -> Motor Pin #2
RoboRIO Analog #1 -> White wire -> Motor Pin #2
RoboRIO Analog #1 -> Black wire - > Motor Pin #4

PDP -> Motor Pin #1
PDP - > Motor Pin #3

As seen [here](RoboRIO Analog #1 -> Red wire -> (33 + 33 + 33 + 33 +33 +33) OHM Resistor -> Motor Pin #2).

My question is how to manipulate the motor from the program. I’m able to see the voltage of the winch and set average bits and oversample bits, but they aren’t affecting the speed of the motor. Sometimes when it runs when the robot turns on, but sometimes it doesn’t.

A realization has come to me: should the winch motor (instead of going directly to the PDP) go to a motor controller like usual but keep the analog input? If so, what function does the analog input serve then?

Every motor must be controlled by a motor controller or spike relay (R34, R35). I do not believe the motor you listed is allowed at all (see R32).

Analog inputs go to the AI ports. To use them, you have to write code which adjusts function according to the current value of the input.

Link was broken but it sounds like your talking about the 6004 RA3 194-06 in the KOP.

As GeeTwo said you must hook up to a motor controller. Pins 2 and 4 are only to read a pulse for each time the armature rotates. That will give you the option for some feedback in your program when to stop the motor…let’s say you want to rotate 45 degrees and stop. It has no affect on controlling the motor at all.

Hooking up the motor to a Spark controller worked perfectly-thanks! And yes, @kprzewodek, that is the right motor and it is legal. Although I have it working perfectly fine (binded its speed to a controller), I’m confused as to what function the analog input serves.

There’s a Hall sensor integrated inside the motor assembly.

Pins 2 and 4 are where that sensor signal comes out.

You can use the analog input on the roboRIO to read that sensor signal.

You can process that sensor signal to determine how many times the motor has rotated, and/or how fast the motor is rotating.

You can use that as a feedback for closed loop control.

.

I’m not familiar with this motor, but I’m confused as to how you would use something with a hall effect sensor on an analog input. My guess (and it is only that) is that the sensor is wired directly to these output leads. A hall effect sensor is generally a digital (i.e. off /on) signal.

I would have connected these leads to a digital I/O port and would have started out using an Encoder object on it to see how that worked.

I was not questioning the legality

It is a square wave and would appear digital. The key is that the signal varies between ~4.5V and ~3.5V which isn’t the right threshold to be read on the DIO. There is currently some discussion about adding a schmitt trigger to further condition to get the right threshold. Maybe there’s a better way.

To detect the rising edges with an analog trigger.

My guess (and it is only that) is that the sensor is wired directly to these output leads. A hall effect sensor is generally a digital (i.e. off /on) signal.

This one is not off/on. It’s high/low.

I would have connected these leads to a digital I/O port and would have started out using an Encoder object on it to see how that worked.

See comment immediately above. That’s why you can’t connect it directly to a DIO port. The high/low voltages do not meet the trip point specs for the roboRIO DIO.