Jump to content

Firmware


jayjay23

Recommended Posts

Teensy 3.2 could be a good point to start with if you decide to build an own board.  You only need an addon motordriver:

https://www.pjrc.com/store/teensy32.html

The old Teensy ++ 2.0 or Teensy 2.0 is mentioned in the code of ovaltineo if I remember right. The ovaltineo code needs to be migrated to ARM to run on Teensy 3.x.

Link to comment
Share on other sites

@jayjay23,

I agree with all.

About being OpenSource, I think the license need to be selected. I also believe that is important to be free for commercial use.
The license can be GPL, which is viral or something like MIT. I prefer the viral GPL.

1.2) I think we could have a schematic and improving it over time while we gather more and more information. Some developers/testers will be more interested on the electronics side. Also, I believe there may be some improvements/hacks on the board to get more features.

I would like to start drawing a very simple schematic. Can you please share the information you have about the pins of STM32F103??

2) Well, you now know a lot!! I will follow you :-)

3) About support, I think you are not obligated to answer.

Link to comment
Share on other sites

19 hours ago, OliverH said:

Teensy 3.2 could be a good point to start with if you decide to build an own board.  You only need an addon motordriver:

https://www.pjrc.com/store/teensy32.html

The old Teensy ++ 2.0 or Teensy 2.0 is mentioned in the code of ovaltineo if I remember right. The ovaltineo code needs to be migrated to ARM to run on Teensy 3.x.

If you like, the Mapleboard mini is a much cheaper alternative to Teensy. $4.50 from a reputable seller http://www.ebay.com/itm/400569863658 

Link to comment
Share on other sites

@electric_vehicle_lover:

GPL should be fine, I actually have not yet thought about so it's missing in the files, but I can add it on the next push.

About the schematics, is your goal a hardware development? If so the question is whether you really want to copy something existing or you just let some decent electric guy design one? I have only basic electric knowhow, nothing to design new circuits, but I can support you if you want to go that direction. My personal focus would keep on coding for existing controllers (I'm open to learn about new controllers from other manufacturers).

You asked about the PIN out, I put a picture of my latest findings earlier in this thread, I can give you that as a libreoffice doc, on the other hand I can offer to put everything I have in my head to think what the PINs are on a picture of the board (this should be some work, but can increase understanding quite a lot, so it should be worth to do it, if you explain the goal shortly).

I have one question for you (as this would be the next step I was planning), can you write ADC code to read in some PINs or help me with finding a good solution for a delay function that keeps the overall system open for further extensions?

One doubt I have is about one filter parameter, all filters take the gyro rate and the acceleration value and return an angle, aditional the take a timer value, one comment mentioned this should be a ms value, does anybody know if it really has to be ms and if so, how to setup a timer accordingly or calculate if from system ticks?

@OliverH:

https://github.com/ovaltineo/SegwayClone

What is nice in this code is the HAL layer (as I have done the exact same for the IMU already).

 

 

 

Link to comment
Share on other sites

@jayjay23

About the schematic, I just can give you an example, of someone who did that for a electric bicycle controller, a chinese and cheap one that used on my bicycle and from which I learned a lot and used to make a prototype of my controller: http://www.avdweb.nl/solar-bike/electronics/ku63-motor-controller.html
That controller uses an unknown microcontroller so we can't reprogram it. With the generic UC using STM32F103, we can do whatever we want and explore the hardware at his maximum :-)
Yes, please send me the information you have. I will design the circuit and do a pull request to your github.

About ADC, I must say I do not have the firmware development ready nor a board to test. Anyway, my old code for the BLDC controller using STM32F10x, have ADC code using DMA:
https://github.com/casainho/EBike-Smart-Controller/blob/master/firmware/adc.c

For timer, systick here; https://github.com/casainho/EBike-Smart-Controller/blob/master/firmware/main.c

One doubt I have is about one filter parameter, all filters take the gyro rate and the acceleration value and return an angle, aditional the take a timer value, one comment mentioned this should be a ms value, does anybody know if it really has to be ms and if so, how to setup a timer accordingly or calculate if from system ticks?
A: If I understand you, if you want to measure time, I think a good idea is setup a counter/timer that increments at a specific rate like 100ns. When you want to start counting, you read the counter value and when you want to stop you read again and subtract the values. Everytime the counter overflows (the total span of the counter limits), an interrupt can increment a variable.

I think systick interrupt should be use for something slow as 1ms or 10ms - example of my code:

 
void SysTick_Handler(void) // runs every 10ms
 
{
  static unsigned int counter = 1;
   
  // need to call this every 10ms
  cruise_control_tick ();
   
  // for delay_ms10 ()
  _ms10++;
   
  // read throttle value and update PWM duty cycle every 10ms
  update_duty_cycle (throttle_get_percent ()); // 1000 --> 100%
   
  volatile unsigned int motor_speed = motor_get_speed ();
  // every 500ms
  if (counter++ > 50)
  {
  sersendf ("%u\n", motor_speed);
  }
  }

For something that must be very quick like 10ns or 100ns, I think we should use a dedicated timer.

On the controller board, do you know if there is a UART available?? Maybe they used for debug their code and we could also use it...

Link to comment
Share on other sites

Hey guys.

 

I've just ordered a TG T3 just a day ago and found this thread today. I'm already really interested in modifying this unicycle :D (other mainboard, firmware, battery etc.)

I would like to contribute to this project. (I found the link to the github repo but i get Error 404).

 

I'm an PHP Dev with some experience in AVR and minor electrical experiences.

 

So it would be nice if i could help :)

Additionally, i could donate webspace / webservices, etc. if required.

 

Greetings from Germany

Link to comment
Share on other sites

I just received my generic electric unicycle :-)

I had to open it and see the controller, even before learn how to ride it. My notes:

  • The controller is very simple and cheap, seems to be near the cheap electric bicycles controllers with the exception that have the IMU ic
  • The LEDs for charging indication are controlled by the main board and not by the battery BMS
  • The charging cable go directly to battery pack and not to the controller board. I believe there is a BMS on the battery pack (just like on electric bicycles)
  • Seems there is a big inductor that can be for a step down voltage converter from the 60V from to something like 12V. After there is a 7805 to provide 5V and a LM1117 provides the 3.3V.
  • The 2 equal ICs with 8 pins each, maybe dual opamps each one. 3 opamps for the circuit of reading BEMF and 1 opamp for the circuit of reading total current (there is 2 big resistors in parallel that seems to be for the current measurement)
  • Motors drivers are done using transistors
  • The commuting mosfets are P75NF758 (STP75NF75)
  • I don't see possible connections for a UART connection that could be used for the development and we could use it also

    @Restless, great!! :-)
    For helping, at least we need to buy the programmer/debuger for being able to flash the firmware we will build.
    Websapce could be great to host documentation files but I think github have a wiki and so we should have all the needed resources for now.

DSC01747.JPG

DSC01723.JPG

DSC01724.JPG

DSC01725.JPG

DSC01727.JPG

DSC01730.JPG

DSC01732.JPG

DSC01738.JPG

DSC01739.JPG

DSC01744.JPG

DSC01745.JPG

Edited by electric_vehicle_lover
  • Upvote 1
Link to comment
Share on other sites

4 hours ago, electric_vehicle_lover said:

My notes:

Congratulations!!! I'm really suprised, you know what you do. All this was the exact same thing I did to find out how the PIN out was, I've only some very few additions:

- The hall sensors can be followed directly

- One of the two I2C channels that the chip has is used for connecting to the MPU6050

- If you follow the lines from side of the chip, you see each ends in a group of transistors (same layout 6 times) for each MOSFET, so this way I decided which PIN is for which H-Bridge MOSFET.

- The board you have has 99% the same layout than mine, I'm just lucky that the SWD /(SerialWire Debug) has soldering holes, look at the first pages of this thread were I made pictures of my controller.

You ask about how to connect to the thing, the chip itself would support SWD and/or JTAG, but JTAG requires more PINs and they are used for the LEDs and speaker stuff already. So of course before booted the chip could theoretically be put into JTAG mode put it will be more work to get access to the already used wires, and once the original firmware runs, it will also reassign these PINs(38-40), so I found it easier to try to use SWD right from the start. SWD is two PINs (37 and 34), if I see it correctly they are just not connected on your board (hopefully not under the chip), so if you are good enough in soldering these size of PINs you can connect a thin wire to the PINs.

I described earlier what I found how to use a JTAG compatible adapter to also work for SWD (you only need one resistor and solder some wires).

You also asked about playing and other posiblities, well this is not my primary goal, but if you are interested, the following PINs are not connected on my board

and could be used for doing something later on:

2 Tamper-RTC / PC13

3 Osc32_IN / PC14

4 Osc32_OUT / PC15

5 PD0 / Osc_IN

6 PD1 / Osc_OUT

13 ADC12_IN3 / USART2_RX / TIM2_CH4 / PA3

32 PA11 / TIM1_CH4 / USART1_CTS / CAN_Rx / USBDM

33 PA12 / TIM1_ETR / USART1_RTS / CAN_Tx / USBDP

So what I found  interesting is USB/CAN connection.

@Restless

I will see that I can reopen the github, could you both please send me your github names so I can add you to the contributors? It would be good if we can work on the same repository all together.

Just yesterday I got another good idea on maybe getting people for the project, it happens that since this week I work for a company who has a multiple floors of firmware developers and there is a forum for introducing all kind of stuff that you like, so beginning next month I will take the chance to tell about the wheel and the firmware project in general maybe there is somebody who finds the idea great and catches fire.

@electric_vehicle_lover:

Oh and I found it interesting that your cables are all soldered, and the mystery SP connector on your board is two cutted wires! :-)

Oh and another thing I would like to highlight, what is the tape you have between the MOSFETs and the cooler? On mine this was

the yellow transparent battery insulation tape and I guess there is something that conducts heat better than that!!!!

  • Upvote 1
Link to comment
Share on other sites

Disclaimer!

@electric_vehicle_lover: In case you add a readme, please add a disclaimer for injuries and so on, as this topic is especially sensitive here, like the ovaltineo.

@electric_vehicle_lover:
 Thanks for the ideas of the systick, I will have a look into that. Regarding ADC, I'm not sure whether ADC with DMA gives really great time improvement or not? For the I2C I read that it should give you a few ms so quite a lot. Oh and I don't know which channels of the DMA can be used at the same time, so I only looked into the I2C first.

  • Upvote 1
Link to comment
Share on other sites

6 hours ago, electric_vehicle_lover said:

My notes:

Another comment in case I've not yet told that, one PIN goes to the area of the power supply circuit that you already described in more detail,

so I guess it's for battery voltage measurement.

Link to comment
Share on other sites

1 hour ago, OliverH said:

I don't want to disturb your conversation. Maybe this can be in parts integrated? 

https://endless-sphere.com/forums/viewtopic.php?f=30&t=65297

 

Hey @OliverH,

sorry if i'm wrong, but the Project you've posted (as far as i can see) is a hardware mod. So not really something we focus on right now.

At the moment we want to build a nice and safe OpenSource FW for a universal EUC-mainboard.

 

Kai

Link to comment
Share on other sites

Development resources

  • protected variable bench power supply
    About getting more developers on the project, I believe the main difficulty can be the investment in hardware for be able to develop and test. For example, when I developed the firmware for the BLDC motor controlor for a bicycle, I used a power supply of 24V on a motor of 24V. The power supply is the cheapest I could found. During the development I shorted the motor a lot of times!!! I even tried to make it run with some pieces of time shorting... I learned a lot by experimentation and the protected power supply is a MUST.

    I found on ebay and from UK, a  DC Linear Bench Power Supply Variable Output 0-100V 0-3A (0-50V 0-6A) + 5V fixed for 300€!! The same price as my unicycle.......
    Anyone knows other cheaper power supply??
     
  • SWD programmer/debugger
    I don't have a SWD and I will buy from Ebay (on Europe source) STLINK V2 compatible for 13€ that includes shipping :-)
     
  • Original control board
    I don't know where to buy it.......

------------------

  • My controller have also the pins for SWD and with holes:
    JQqbgT1.jpg

    About the lack of UART for debug - I found in one site:
    OpenOCD supports many different adapters including ST-LINK/v2 and has recently added support for SWO tracing which allows you to see the output of STDOUT e.g. printf, right inside your Eclipse terminal. In my opinion, this is an incredible and priceless debugging tool.

    Seems that with SWD there is a channel for printf messages to outside. That's not bad... But I was expecting maybe having a terminal in firmware so we could send commands to the board, maybe using a chap UART<->bluetooth module
     

My name on github: casainho.

The SP connector on my board, I guess are the wires that are shunted when the board is produced and when they install on the UC and calibrate it, they after cut the wires. If we boot the board with the wires shorted, the board enters on the calibration mode of the UC.

 Regarding ADC, I'm not sure whether ADC with DMA gives really great time improvement or not? 
A: That ADC is configured to:
ADC_ContinuousConvMode = ENABLE;
ADC_SampleTime_55Cycles5
And so it is continuous measuring the signal at that 55 cycles frequency. After each read, the DMA will place the result on address of  variable  &adc_values So we can just read that variable and we will have the latest value, without any CPU intervention.
The DMA can also place the value to circular array - maybe this will be useful for filtering the signal...

For me is ok t ouse GPLv3 license for this firmware.

I use Eclipse for flash and debug using OpenOCD. On Eclipse I can see the values of any registers, variable, put breakpoints, watch values on memory and variables, see the disassembly code, etc.

My main worries right now are getting a bench power supply and a mainboard to play with...

Edited by electric_vehicle_lover
Link to comment
Share on other sites

Ohh, yes, you are right, it just absolutely didn't catched my eyes as I was only comparing were these points are on my board. Ok that's great if you have these too and know already how to connect, I didn't knew the STLINK is so cheap, somehow I expected something else.

Regarding the SWO if I'm not wrong that's an additional wire you can have for SWD? So maybe it's not directly working, but if you find something more on this topic just let me know. My last research was how to use gdb to show the variables of interest.

Link to comment
Share on other sites

Hey @electric_vehicle_lover

 

i guess we should pick one mainboard as our "(in)official" Dev-Board, so we wont get in trouble (in basic dev state) with possible hw differences.

As @jayjay23 posted we could use this one Click me!* (i asked the seller for an inquiry: "1pcs price is 12USD,if with china post shipping ,price is 28USD." to Germany) if we order a couple together (for devs in same country) we might even be able to save on shipping. Just as an example.

Sadly i couldnt find a Bare Mainboard on Banggood (less shipping costs and easier for german customs with an NL relay warehouse).

 

300 bucks for a Power supply ... ugh thats a couple $ to much for me :D

 

*No warranty this controller is good to use, just a reference

Edited by Restless
Link to comment
Share on other sites

That would be ok for me, as a first try I would like to see whether what I have today already fit well enough, but if during development we find it has some nasty differences, we can stick to the exact same board. As I said I would like to have at least one for another wheel I would like to build plus a spare part for development, so if you order something to germany you can include 2-3 for me.

If you are ok, to not reach 67.2V but 60V, this one for 140,- + 15,. Euro shipping is quite well I think (it's the cheapest I could find): http://www.ebay.de/itm/Labornetzteil-PowerLab-605D-60V-5A-LED-Labornetzteil-Netzteil-Netzgerat-Trafo-/252100350714?hash=item3ab25a12fa

I actually thought that of they are serializable (I have to read into it which kinds of supply allow that) one could buy two of them (the dual cost 390,- also too much for me)

 

Link to comment
Share on other sites

 

11 hours ago, electric_vehicle_lover said:

So we can just read that variable and we will have the latest value, without any CPU intervention

Ok, if we have free channels that would be good, then we can achieve shorter cycle times, which should improve smoothness.

@OliverH

Yes the git repo has a wiki (finally I found it :-D), I just started with some basic structure, but not much content yet https://github.com/qjayjayp/myewheel.org/wiki

44 minutes ago, OliverH said:

The EM Microworks 30B/ 30 BS boards should also be usable with your code?

Currently this is not the first focus, but the boards look quite similar (same STM32 controller, same MPU6050, so my main thought about adjusting to that board would be the motor controller, which looks different, so this board once there is interest, would need to be analyzed the same way we do now for the generics, and this also need to include measuring analog values and think about their interpretation. But as a short summary I would guess this should be a rather easy board to adjust to.

Link to comment
Share on other sites

1 hour ago, jayjay23 said:

If you are ok, to not reach 67.2V but 60V, this one for 140,- + 15,. Euro shipping is quite well I think (it's the cheapest I could find): http://www.ebay.de/itm/Labornetzteil-PowerLab-605D-60V-5A-LED-Labornetzteil-Netzteil-Netzgerat-Trafo-/252100350714?hash=item3ab25a12fa

I actually thought that of they are serializable (I have to read into it which kinds of supply allow that) one could buy two of them (the dual cost 390,- also too much for me)

 

As a clueless noob, I follow your project with awe and admiration. So, this question is likely pretty dumb: why don't you just use the regular EUC charger to power up the board for testing? Probably with a large capacitor to even the wobble and an adjustable electronic fuse (something like this: http://www.ebay.de/itm/Elektronische-Sicherung-DC-1-80-Volt-0-5-4-Ampere-/111233859874?hash=item19e60e0122:g:~g0AAOxy63FSoyna)? And maybe one of @hobby16's Charge Doctors (http://forum.electricunicycle.org/topic/346-charge-doctor/#comment-3462) to check voltage and current?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...