How to send randomly generated values to BLDC via FOCBOX

Hi, HELP! I want to use BLDC Tool for Mac to send randomly generated rpm (range = 500 to 6000) and duration (range = 30s to 72,000s) values to precisely control a BLDC motor (KEDA 63-64) via my FOCBOX. Any help, alternative directions or suggestions (except for the obviously obscene ones) would be greatly appreciated. Yes…I am a NOOB. Thanks, KDoc.

need better explanation. What do u mean random value?

I am using a random number generator to generate a list of motor speeds and durations, for example; 578 rpm for 372 s, 4076 rpm for 5471 s, 2097 rpm for 3201 s, etc., etc. I want the motor to soft shift to these speeds and hold them for the specified duration and then move on to the next set, and so on.

1 Like

Maybe you could take a look at Vedder website for the 4.12 Vesc, which is the same on a firmware level as the focbox http://vedder.se/

Hi Johnny I initially got started at Vedder’s site. This is how I ended up with a FOCBOX. I have come at this from the ebike site endless-sphere.com and setting up the parameters for this motor and the FOCBOX is doable through Kepler’s tutorial. What I am hoping to find is a way to interface my MacBook and the FOCBOX via BLC Tools for Mac to precisely control the motor. I could very easily be missing my solution from Vedder’s site, but it seems to me that Vedder’s programming tutorial is for downloading the programming tool, setting the motor parameters and then setting up the remote control connection. Please correct me if I am wrong, but I was assuming that the programming tool I need is BLDC for Mac (which I have already) and I was hoping for some help with my specific control parameters. If I am missing the point here, please let me know. At this moment the only point I have a firm grasp of is the one on the top of my head. PS The reason I am on esk8 is that I have found the posters on this site to be very knowledgable, cutting edge and generous and you seem to really limit the abuse that plagues other sites.

I don’t know how handy you are with software, but i know i’m fucking useless so this would be my solution:

Use an arduino to generate a ppm signal, put the focbox in duty cycle mode and bench mark the erpm with each given signal. Create a psydo random sognal with the arduino and monitor the results via the real time data

this is either a very advanced or completely useless application. i can’t tell which…

either way its a custom application, you will need programming skills. and you will likely burn out more than one esc trying…

Whats the point? what do you actually want to accomplish?

Hi Blasto, Thanks for thinking about this. I like a good portion of this solution. I was hoping to avoid the Arduino, but I may have to, as you suggest, “generate a ppm signal, put the focbox in duty cycle mode and bench mark the erpm with each given signal”. I previously decided that while an Arduino could generate a pseudo-random number, generating random numbers from a Gaussian distribution, where the randomness comes from atmospheric noise is more robust. I have the process to continuously generate the random values I need. I now just need a way to get my computer to tell my motor to spin at these values…damm it. So I am still unclear about how to get the random data into the ppm signal. Any thoughts?

Hi Saul, I suspected this question(s) was coming. I hope this application lies somewhere in the middle of the spectrum between “very advanced or completely useless”. I am trying to get my motor to drive a fixed gear bicycle wheel (in a trainer) at the random values mentioned at the beginning of this post. I am trying to get leg muscles to force neurons to accept overriding and completely random inputs. It is for the treatment of a neuromuscular disorder and so far the esk8 community is the only one I can find that I believe might have the intellectual flexibility, design and construction skills, coupled to an inherent ability to test the crazy stuff you actually build, to be able to give me some guidance. So I suspect, like you, that this might pendulum between “very advanced or completely useless”, but the theory behind the treatment is valid.

2 Likes

Why not pipe the random numbers through the Arduino? You can just send them as Strings, especially since you are only sending new commands quite far apart

Hi Maxid, This might be the solution. My Arduino skills are non-existent, but I will get on this. Anyone with any specific suggestions for deigning/building the Arduino, or any other thoughts/possibilities please let me know. Like I said…I am a NooB.

There is a Arduino Library called VescUartControl by RollingGecko, it’s currently working for fw 2.18 and he’s looking for testers for newer firmware. Also, you can directly set the RPM Values via UART using this library (with the newer firmware anyways). Then you could send the random values to the arduino via Processing (i haven’t used it so far but i think that’s what to use).

This actually sounds very interesting. an surely a pretty advance biomed Engineering application. (Read: FUN!) I have a good amount of programming and arduino skills. and fixie thats not in use.

Can you give me some reference to why you want to use “random” input?

also the vesc/focbox has a pretty powerful processor with some unused resources, so it can likely be done directly with a custom application + vesctool. still needs programming but no extra hardware.

Keep in mind that all you need from the Arduino to drive the VESC is a PWM signal (PPM is what the remote uses but that is “translated” by the receiver to a PWM signal) - see also https://hackaday.io/project/12123-electric-longboard/log/42519-vesc-finally-arrived for example.

So doing this should be really easy (far less time consuming than fiddling with custom VESC firmware).

Just look for PWM tutorials for Arduinos and how to send and convert some text over USB. You should have this up and running in an hour.

For the more professional version without an Arduino: There must be a way to connect to the VESC the same way as VESC-Tool does it and then just send the raw UART commands. But I can’t find a tutorial and since the Arduino solution is so easy, cheap and quick I am not sure if it would be really any better.

From what I just read and understood, I’m guessing your goal is to prove a concept through a randomly generated over time Gaussian distribution and using the result to drive a motor. From what I read and understood about the muscle part, you want to force stimulation of muscle in the opposite direction by making the muscle send the action potential into the neuron. That’s cool.

This is a bunch of spiel/thoughts running. Ignore if you don’t want to read it. I’m just trying to help I know the Gaussian distribution delivers positive and negative values with an average being the greatest towards the middle. Trying to brute force the numbers into something…, I would try to set the X and Y axis values in a range but what would I label the X and Y axis? I know a motor gives off angular velocity and torque and you want to control its RPM for a set amount of time through the PPM function. The limiting factor is the RPM of the motor.

Hi Jo, Thanks for the resourse. I took a look at the Arduino Library. I need some time to explore it. Any help in setting up the Arduino is greatly appreciated, although I now have the benefit of the next few responses so I am trying to refine my request as your collective assistance accrues. A big thanks to everyone that is thinking about this. I am trying to trace how my values will travel from my computer to the motor and what the difference (if any) there is between UART and USB for this application. I feel the thin ice of apples and oranges may be melting under my feet. I appreciate everyones patience.

Hi Saul, Thanks for the positive response and relevant, clarifying questions, especially with your previous Futurama reference as I really feel the oscillation between Philip J. Fry (with my limited electronic and programming skills) and Farnsworth (I am comfortable with my neuromuscular interface design with a solid neuroscience background). So on with your question; I am using true random speed and duration values because the brain has a remarkable knack for detecting and accommodating patterns, resulting in iterative behavior. By iterative behavior I mean the capacity to repeat a task over and over to the point where the task response becomes embedded. This works well when the brain and body are well synchronized, but not so much when either has gone awry. One tends to lead the other in a very undesirable direction. So before the muscles atrophy into a non-desirable pattern it is possible to push large muscles to force the neurons to try to accommodate a reversed (hence new) neural signal (“you don’t tell me what to do…I tell you what to do”). It is then possible to allow the neurons to reestablish control, albeit with a new neural output, and then repeat the disruption as needed. The use of a random signal is to ensure the brain cannot settle back into a physically destructive pattern, and let me be emphatic, the brain is a pretty tricky customer and it can smell a non-randomized rat a mile away. Therefore, a computer generated random number is not adequate because the number is not truly random and the brain has a way of detecting this and developing a work around. It took me a while to find and generate a true random number generator, but I feel comfortable with this part of the (non) equation. I have generated a number of sets for this project. I just need to get the damn values from my computer to my motor.

I got stopped at the computer/Focbox/motor junction, but believed, as you do, that programming the Focbox would be enough, and that no new hardware would be required. It seems that if I do need hardware that an Arduino might solve my problem, but I was/am hoping for a Focbox programming solution or some other simple way to drive the motor with my random values.

I am also dogged by the future in this. For now I will gladly accept a wired solution with a computer operator (me) pushing the values, but eventually this will require a bluetooth, wifi solution when I cannot physically be with the patient (a close friend) that I am creating this for. So I need to get the mechanics of this working, but I will eventually have to push each ensuing treatment/workout over wifi (Arduino?), but that is for later.

PS Returning to the Fry-Farnsworth analogy the last programming I did was in FORTRAN. P Also, see my response to chutney below for fixie information.

Hi Maxid, Hopefully you have read the last few responses because I have tried to address a few of your insights. Both of your suggestions regarding; “PWM tutorials for Arduinos and how to send and convert some text over USB” and especially “There must be a way to connect to the VESC the same way as VESC-Tool does it and then just send the raw UART commands.” are worth investigation. I will try to get on this. Please keep any thoughts and resources coming.

Hi chuttney, I am glad I was able to “curry” a response (sorry) and any help is welcome. I set the parameters for time by determining the “normal” work out length my friend could maintain when he was riding unimpeded (healthy), including warmup, workout and warm down. I then generated random duration for each of these periods. I then determined the minimum and maximum cadence he might be comfortable with in these three workout intervals while also increasing the maximum cadence to include super high values achieved in spin workouts with very fit elite athletes (cadence as high as 300 rpm for a few seconds. This seems incredible to me, but we will see, plus this max value can easily be changed). I then generated random cadence values within these parameters. The idea is to disrupt not just the present disfunction, but also previous “healthy” cadence patterns. The BLDC motor I have has a non-load speed of about 6000 rpm. When coupled to a 27” wheel with a fixed gear I get crank cadence within the range I am looking for (at least to begin with). I internally seized an old Shimano Dura-Ace free-hub body and using the myriad of gear size cogs available from my old stash and a few local bike store trash bins I am able to get pretty good cadence selection with a direct drive chain set up.

I realize this thread is getting a little away from an esk8 topic and I do not want to hijack or disrupt this site. I will move it (uncertain where to) or entertain thoughts from esk8 users on where to put this if it becomes a nuisance. I really appreciate the insight, information and suggestions that have come from this community and as I said in the beginning this community is really unique and is responding in exactly the way I hoped for. Thank you.