|
|
Joined: Jan 2009
Posts: 667 Likes: 14
Nobelhobel
|
Nobelhobel
Joined: Jan 2009
Posts: 667 Likes: 14 |
Hi Marcus Double wow! How are you doing? First wow ist for the completion of this rather engaging project, for the reverse engineering of the AFAM and for the electronics design! And, knowing you, I assume it's all working like a charm. Second wow is that you find the time and stamina to tackle such a complex task during your trip. Great! I'm also amazed you managed to write the controller logic in less than 500 lines. The only thing that worries me here, if I may say so, is the monolithic structure of the actual control loop with lots of delay statements. How do you software-test this? Close to impossible, I would argue. If you're up for some refactoring I'd suggest you first draw a state-event diagram for your logic to abstract from individual state variables, then implement that. Here's an example (PDF) from my Arduino boiler controller (the rest of the code is there, too). But despite my criticism, your work is awe-inspiring. Once more. Well done, mate! Happy travelling -- oliver
|
|
|
|
|
Joined: Jun 2016
Posts: 50
on the road
|
OP
on the road
Joined: Jun 2016
Posts: 50 |
Hi Oliver, You introduced me to the Arduino back in Brazil so it's all your fault ;-) I just wrote the code by thinking through all the logical steps I needed, as you know I'm not a software engineer! During the development I had the serial port enabled and streamed data to my laptop. This allowed me to see what was going on in real time (I removed this code for the in use software version). I also set up a counter so I could see how quickly the 'software loop' was running. The two things that slow down the loop are the rpm and vehicle speed calculations. If the engine is not running and/or you are not moving the calculations for the rpm and speed wait until the 'time out' I have set, this is a long delay. Even with this delay and 'printing' all the data to the serial port the software was looping 4 times per second which I think is more than quick enough for this application (if you are moving the loop will be even faster). The software only uses 5% of the memory and I have already developed an artificial horizon using the 9 axis shield and is displayed on a 1.77" TFT screen. It will warn you if you approach your 'roll angle' and can turn on the buzzer or check light to get your attention! The website update is on its way, I just need to build a booster for the signal going to the display as the Arduino is mounted under the drivers seat and the cable runs are a little long. I have also used an Uno to simulate my speed sensor when I had a fault with it, again it will be posted up a few weeks. ![[Linked Image von i67.tinypic.com]](http://i67.tinypic.com/iptl3s.jpg) I will try and learn the proper software engineer way of doing things for the next project! All the best, form a very wet and raining Suriname
|
|
|
|
|
Joined: Jan 2009
Posts: 667 Likes: 14
Nobelhobel
|
Nobelhobel
Joined: Jan 2009
Posts: 667 Likes: 14 |
Hey Marcus You introduced me to the Arduino back in Brazil so it's all your fault ;-) I'll happily admit to that! I just wrote the code by thinking through all the logical steps I needed, as you know I'm not a software engineer! … I will try and learn the proper software engineer way of doing things for the next project! No worries! As I wrote, you did amazingly well. In general, C++ is not an easy environment to get into, but on one hand Arduino makes it as easy as possible and on the other hand does not foster or encourage good software design practises. And since your work will hopefully inspire more people to do similar projects, I thought I'll drop in a hint towards a more robust software structure and design process. As part of my own work I developed a small framework to ease the development of these kinds of controllers. I.e. to facilitate the use of logging to the processor's flash memory, to read and write configuration parameters (also on flash memory) and to base the controller's main loop on an easy-to-understand state-event automaton ( github). What's still missing in that framework are stand-alone examples that make it easy to understand how the elements of the framework can easily be taken advantage of (the current examples folder contains the modules I use to software-test my own code). I'll deliver those in the near future. Wishing you lots of sunshine, clear roads, happy people and no bugs (I actually mean the ones that fly but realise you wouldn't want any in your projects either ;-) -- oliver
|
|
|
|
|
Joined: May 2015
Posts: 610 Likes: 7
Suchtiger
|
Suchtiger
Joined: May 2015
Posts: 610 Likes: 7 |
Hi Marcus,
good stuff, congratulations.
What is the main reason for the need of a "computer" / PLC? Couldn't the diff lock control be done with some simple switches and feedback LEDs or indicators?
Regards Raphael
Fuel-to-Noise-Converter (F2NC) Iveco TurboDaily 4x4 40-10 WC, FGst-Nr. ...5939317
|
|
|
|
|
Joined: Jun 2016
Posts: 50
on the road
|
OP
on the road
Joined: Jun 2016
Posts: 50 |
Hi Raphael,
Yes it could be done with a few switches and relays but you would loose the safety features of the speed limits. But it was also to give me something to play with in my spare time.
Hi Oliver,
Things are progressing and I will look to better structuring. I have now got the 9 Axis motion sensor working (needed to change some of the Bosch library to get it to work with the Due for some reason). I have built a signal booster which also matches the signal levels between the Uno (5V) and Due (3.3V) so they can communicate over a long serial link. I have the 9 axis data streaming to the Uno from the Due but some more research/learning is required on my part before I crack this data link completely. The idea is the Due is mounted solidly below my seat doing the AFAM and gyro and the Uno will have the display and possibly some buttons. I plan to add extra functionality like the Horizon and other ideas I have in the pipeline. Running the 9 Axis sensor and the AFAM functions the Due is still clocking through the main loop 3 times a second, which is more than enough.
|
|
|
|
|
Joined: Jun 2016
Posts: 50
on the road
|
OP
on the road
Joined: Jun 2016
Posts: 50 |
I have now re-written most of the code, using routines and generally cleaning things up. It works well, tested in the Suriname jungle! There is also a mode to engage only the rear lock. All updated on the website at the original link above.
|
|
|
|
|
Joined: May 2005
Posts: 7,636 Likes: 133
Daily96 40.10W
|
Daily96 40.10W
Joined: May 2005
Posts: 7,636 Likes: 133 |
Hi Marcus,
witch fault code reader do you use ? Apparently it works quite well with the IVECO engine ECU
(Sorry for OT)
Regards
Juergen
Gruß Juergen
|
|
|
|
|
Joined: Jun 2016
Posts: 50
on the road
|
OP
on the road
Joined: Jun 2016
Posts: 50 |
Hi Juergen,
I use an EASY and a PicoScope. However, the EASY is no help for the AFAM as there is no computer, it is just hard wired logic circuits. I am working on a PCB that will be a direct replacement for the AFAM circuit board. More to follow in a few months.
Regards,
Marcus
|
|
|
|
|
Joined: May 2005
Posts: 7,636 Likes: 133
Daily96 40.10W
|
Daily96 40.10W
Joined: May 2005
Posts: 7,636 Likes: 133 |
as I wrote it`s OT - I really meant the engine ecu, not the AFAM. So the screenshots on your website are made with EASY, i.e. this one from here on your site . ![[Linked Image von tuckstruck.net]](http://www.tuckstruck.net/wp-content/uploads/2016/09/Turbo-2.jpg) That`s a nice visualisation what happens and how the ecu works.
Gruß Juergen
|
|
|
Moderated by Burgerfrau, DaPo, Dieter, Flashman, juergenr, Monny, Ozymandias, Peter, Phil, rovervirus, Tordi
Posts: 624
Joined: June 2002
|
|
|
1 members (Gerscher),
183
guests, and
0
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Foren37
Themen44,384
Posts675,497
Mitglieder10,098
| |
Most Online1,525 Sep 24th, 2025
|
|
|
|