Does anyone on here know if the capacitor-resistor combo attached to a pwm output pin of an Arduino gives a decent analog output?
People replied a lot while I was sleeping. I''m not going to give the same response to everyone who was asking what its for, so I'll just say it here. I want to use an arduino to spoof the 0-5V analog throttle signal on this ebike i'm building.
As best I can tell, ebike throttle units put out an analog voltage without any kind of data signal, but somehow the e-bike knows the difference between a real throttle, and one made out of an arduino, or even made out of a bench power supply. It will only run when connected to an actual ebike throttle

I'm getting somewhere now. It's not giving full throttle but it is giving some throttle.

I had to hook up the throttle unit in parallel with the Arduino for the bike to accept inputs from the Arduino.

This might work out ok because i wanted to have a throttle lever and pedal assist anyway.

More testing to do still!

I briefly had it working without the throttle connected. I had put a 1.2K resistor between the positive and ground wires and that did it. The bike was under control of the Arduino. Then it just stopped working and hasn't worked since.

The Arduino still works, and the bike still works if I hook a regular throttle to it. Mysterious

@MLE_online aha! I bet I know another answer!

Part 1: was the voltage TO the orig throttle (pot, I suppose) *slightly* less than 5V?
Part 2: did you ground the microcontroller to the "low" voltage lead of the 3 wires, or the "real" system ground?

What I think is going on: I think the signal your giving it is "out of range" like I said, the cart I have is picky, if the "value doesn't look right" it does a safety shutdown. You might find by limiting the max and min PWM levels, you find a "happy place"
I suggest starting it at 50%, and slowly dialing up/down to feel out the limits.

you got this! Were all counting on you!

:]

@RueNahcMohr It's a full 5V going to the original throttle. The original throttle is not a pot. It's a hall-effect thing.

I grounded the microcontroller to the black wire that is identified as ground.

I have already limited the max and min PWM levels so they match the voltage limits that the throttle outputs when it's at the bottom and top of its range

@MLE_online interesting, they must have a really curious "safe input" system in there.

I suppose you cant see the chip in the throttle, I suspect its a hall effect pot.

Does it look like this?

@RueNahcMohr It doesn't look like that, but it's probably similar inside. Does yours have a red, green, and black wire?
@RueNahcMohr So it's probably the same. These hall-effect throttles all seem interchangeable with each other. For testing purposes right now I'm using one from an escooter. The bike is perfectly happy with it

@MLE_online based on what I learned here, it must be ripple in your pwm freaking it out.
With the 1.2k resistor, its fine with the bench power supply signal?

'tomorrow' I know....

@RueNahcMohr the 1.2K resistor isn't between any two lines on the arduino. It's between the V+ and ground wires

@MLE_online I know.

scope this a second.... ( I know the filter might not be arranged right)

@RueNahcMohr I will try on saturday. I'm done with it for today and I have ceramics tomorrow
@MLE_online ok, its my understanding of what you have right now.
@RueNahcMohr the only thing you have wrong is that the 1.2K resistor is not connected to the positive 5V rail of the arduino

@MLE_online ! your powering the arduino from the throttle supply? oh, I wonder if thats the issue...

I'm going to come up with a crazy circuit you can try or not, but that I think might work.

:]
I don't suspect you will try it, I dont know why I'm driven to solve these puzzles..... oh right, core of personality.. ugh...

@RueNahcMohr I'm not. It's powered from a USB battery bank. That's why the positive side of the resistor isn't connected to the arduino. I've only tied the grounds and the signal lines together
@MLE_online ah, so my diagram is good then!
@RueNahcMohr no it's not! You have the +5V of the motor controller and the arduino connected together

@MLE_online ah! miscomm. the inner box is the arduino, I didn't intend to say its + is common!

the outter box is meant as your arduino conditioning circuit.

heh, diagram fail Rue.

@MLE_online hmm, I think you have some CDS cells left over from a project that was light sensitive...

omg wait, is my brain cataloging what other people have too? ....