Popular Post jayjay23 Posted November 4, 2015 Author Popular Post Share Posted November 4, 2015 Hi everybody, definitely this should be a open source project, I'm not planning to sell any development, anyway I think the only way to progress faster is together. This does may not exclude that some company takes the code add some features and uses it for their purpose, but the first stage to be reached is something that can be used anyway. To grow the team I would like to have a short discussion about what is the general idea (the complete puzzle), what are first goals, and what are the skills and areas people who can contribute fit best. I appreciate having good ideas, but I think the picture is not complicated so the main task is probably just to work in certain areas. So I can start with the picture here: 1.) Documentation: 1.1.) Project setup is a point, I agree to you (@electric_vehicle_lover), should be anyway quite simple, if I got it right it's only explaining directory structure and gcc-arm download/unpacking. 1.2.) PCB Documentation: My very personal opinion is that we may not need a complete PCB layout, I actually think this is a lot of work and quite error prone too, the result should anyway just be how the controller(s) are integrated into the picture and as our goal is to write code for the controller I think it's enough to know the interfacing to the controller which could be a one time analysis. I thought about having good resolution pictures of the controllers, but during analysis you need to turn it over a lot maybe use a flashlight to see inside the board or just make some circuit path more visible, anyway maybe such can be used too look up some resistor values or alike. Now that I think about it what would be easier is to take such a photo and mark the circuit groups and their usage. Such and other forms of documentation is probably most useful - beside code development - to compare different boards and see how the code could be reused between them. 2.) Code I have had a look at some of the existing codes already and I would like to draw a simplified (but good for starting) picture of what I understood, so please let me know any comments or additions! The basic workflow should be like this: 2.1.) Get IMU raw data 2.2.) Convert the raw data (some with trigonometric functions) to physical known values/units. 2.3.) Filter the data (by one of the well known filters like Complementary or Kalman filter), output will be the axial orientation of the wheel 2.4.) Feed the data to PID regulation formula (there are parameters for the components which need fine tuning, I have no experience here and I'm unsure whether there can be a general approach or a systemindividual solution) 2.5.) Output of the PID regulation is a amount (unit unknown) of adjustment needed to keep the wheel upwards 2.6.) BLDC Controller I've seen simply code that just converts the PID output directly to motor torque (without even looking at the motor rotation). My first guess would be that it's best to use the PID output to get a certain amount of RPMs (measured by hall and back EMF). The code on mikrocontroller.net only uses hall sensors and as far as I've seen it has no control of speed/torque or alike, so it's very basic. So here we have quite a lot of work, the controller code should take a desired RPM as input and regulate itself by measuring the real RPM and adjust torque to achieve the desired RPM. I'm unsure whether this can be done (like in the mikrocontroller.net code) with separate timers or during the main loop. Overall response of the wheel could be faster if it's done with separate timers (if possible). 3.) Tasks on the way / open questions / things to clarify So from the above rough workflow and documentation you can derive all kind of areas to work for. So what I would like to do with everybody who want's to take part is just to get all kind of ideas to complete the picture of course (but maybe this need to be refined 'on the way' with some experiments and practical exercises), but also decide who can work on which area. 3.1.) The IMU stuff should be the easiest (this is why I started with it), as it mainly uses a ready made library. The MPU6050 is not interrupt driven, but still it could be read via DMA, and use the time during DMA transfer to query the other input channels (ADCs for: back EMF, current and battery voltage). 3.2.) The PID stuff is so simple it's just copying one or a few lines of code. 3.3.) To get more narrow to the BLDC controller I had in mind first reading the inputs (hall sensors and back EMF (and additionally current and voltage)), then using the mikrocontroller.net code to get the H-Bridge and PWM stuff, but extending it for using hall and back EMF RPM measurement. 3.4.) H-Bridge control will also have influence on how regenerative breaking happens (fine timing issues should make the difference here), but as of my knoowledge today this is something to be done 'on the way' or when approaching the issue in more detail. Of course there are more 'features' like switching on the LEDs according to the battery voltage, but I think this is very easy. Other features like bluetooth and alike should all be a second step after getting the basic workflow up. Also please keep in mind that if we develop publicly (open source) there will be support efforts, ranging from, 'Hey your two source code files doesn't make my wheel faster, actually it's not working at all now, what should I do?' to 'I've changed these ten files, I get the following error, what to do?', well probably also more useful input, but you get the idea, right? So please let me know all your input and if we have a common idea and plan we can go on to work on the different areas. 4 Quote Link to comment Share on other sites More sharing options...
OliverH Posted November 4, 2015 Share Posted November 4, 2015 (edited) Here's the link mentioned today: https://github.com/ovaltineo/SegwayClone http://www.diyelectriccar.com/forums/showthread.php/ovaltines-segway-clone-89471.html Edited November 5, 2015 by OliverH 1 Quote Link to comment Share on other sites More sharing options...
OliverH Posted November 4, 2015 Share Posted November 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted November 5, 2015 Share Posted November 5, 2015 @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. Quote Link to comment Share on other sites More sharing options...
robca Posted November 5, 2015 Share Posted November 5, 2015 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 Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 5, 2015 Author Share Posted November 5, 2015 @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). Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted November 5, 2015 Share Posted November 5, 2015 @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... Quote Link to comment Share on other sites More sharing options...
Restless Posted November 6, 2015 Share Posted November 6, 2015 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 (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 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted November 6, 2015 Share Posted November 6, 2015 (edited) 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. Edited November 6, 2015 by electric_vehicle_lover 1 Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 6, 2015 Author Share Posted November 6, 2015 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!!!! 1 Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 6, 2015 Author Share Posted November 6, 2015 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. 1 Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 6, 2015 Author Share Posted November 6, 2015 Is it ok for you to use GPLv3? http://www.gnu.org/licenses/quick-guide-gplv3.html 1 Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 6, 2015 Author Share Posted November 6, 2015 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. Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 7, 2015 Author Share Posted November 7, 2015 16 hours ago, electric_vehicle_lover said: The commuting mosfets are P75NF758 (STP75NF75) I always wanted to look that up but never did it, well it definitely has no problems with ampere or voltage ratings, but it's continuous power is just 300W. Quote Link to comment Share on other sites More sharing options...
OliverH Posted November 7, 2015 Share Posted November 7, 2015 (edited) 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 Edited November 7, 2015 by OliverH Quote Link to comment Share on other sites More sharing options...
Restless Posted November 7, 2015 Share Posted November 7, 2015 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 Quote Link to comment Share on other sites More sharing options...
OliverH Posted November 7, 2015 Share Posted November 7, 2015 (edited) Hi Kai. I thought I read something with PCB also. So maybe I mixed something up. After having an OpenSource Firmware next goal will be tweaking/ redesigning the PCB anyway Edited December 17, 2015 by OliverH Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted November 7, 2015 Share Posted November 7, 2015 (edited) 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: 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 November 7, 2015 by electric_vehicle_lover Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 7, 2015 Author Share Posted November 7, 2015 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. Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted November 7, 2015 Share Posted November 7, 2015 I just edited my message - please read. Quote Link to comment Share on other sites More sharing options...
Restless Posted November 8, 2015 Share Posted November 8, 2015 (edited) 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 *No warranty this controller is good to use, just a reference Edited November 8, 2015 by Restless Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 8, 2015 Author Share Posted November 8, 2015 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) Quote Link to comment Share on other sites More sharing options...
OliverH Posted November 8, 2015 Share Posted November 8, 2015 The project should be well documented that others could participate from your progress. Have you planned using some kind of wiki page? Is there a GitHub avallable? The EM Microworks 30B/ 30 BS boards should also be usable with your code? Quote Link to comment Share on other sites More sharing options...
jayjay23 Posted November 8, 2015 Author Share Posted November 8, 2015 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. Quote Link to comment Share on other sites More sharing options...
Tilmann Posted November 8, 2015 Share Posted November 8, 2015 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.