Registration Notice

Due to increased spam, forum registration must be manually approved by a moderator! Please see this post for instructions.

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #30 on: January 26, 2019, 11:33:21 AM »
Hi Neil, I also used those cheap VNH2SP30 carrier boards when I was first testing. At some point the money you spend will equal what it would have cost you to just buy the Pololu Qik 2s12v10 which is very similar to the Scout! But then you wouldn't have the fun of coding and frying things.

The last version of the Rev 10 firmware can be found on this page (it's just a hex, use OP Config to flash it to your Arduino). You can also see the Rev 10 schematic on that page, which you will want to follow.

But, you can actually still use the code on GitHub, which will let you see how it all works. You just need to change the line at the top of the OpenPanzerScout.ino file, around line 30:

Code: [Select]
    // Motor Chip Selection
        const uint8_t MotorChipVersion =    2;          // 1 - VNH2SP30, used on Scout boards through Rev 10
                                                        // 2 - VNH5019,  used on Scout boards from    Rev 11

Set MotorChipVersion = 1 to revert to the VNH2SP30 version. In fact the only real difference is in the way it reads current draw since the two versions of the chips report it slightly differently.

Have fun testing and keep us posted on your results!
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline johnnyvd

  • 169
    • View Profile
  • Netherlands
Re: Home Build
« Reply #31 on: February 06, 2019, 01:20:23 AM »
Wow, i just found a good source for the Polulu in Europe: https://www.tme.eu/nl/details/pololu-1112/modulaire-motorcontrollers/pololu/qik-2s12v10-dual-serial-motor-controller/# only 66 euro's if you buy three or more..
This even comes close to building my own scouts..
* E-75 / E-100 PAK44 "monster" - in progress
* Sturmjagdtiger PAK44 - in progress
* pz.kpfw KV-2 754(r) - in progress
* T-34 88mm "Kurland Tiger" - in progress

*

Offline Ncartmell

  • 19
    • View Profile
  • Poulton-Le-Fylde, Lancashire. UK
Re: Home Build
« Reply #32 on: February 20, 2019, 04:12:23 PM »
Hello Luke,

Making slow progress, I have managed to modify the Instructables code to drive a Scout using USB.

Only basic Forward, Reverse, Left, Right, Speed Up/Down and LED's On/Off.

Enough so you can test the functionality without TCB and/or Servo Tester.

Hopefully I will then be able to get my Scout's working.

I have a rough idea what is wrong with each of them.

I have made a small Vero board interface adaptor with LED's so the TCB can work with the UNO/Motor Shield.

Now to modify your code.

On Github you have a main file and then some individual smaller files.

The main file seems incomplete without the others.

So do I need all the files?

If so how are they linked?

Sorry for the dumb questions, software was my weak point and the last time I did any coding was 1987.

The total cost for the UNO, Motor Shield and Vero board will be $10

It is interesting playing with these bits.

Best Regards

Neil

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #33 on: February 20, 2019, 06:43:09 PM »
Browsing back through the last few posts, it seems as if you are trying to create your own Scout from off-the-shelf parts with a UNO as processor and some code you found on Instructables. It sounds as if you have gotten the Instructables code to work, and now you have whatever functionality it gives (apparently control from your computer), but obviously it does not have the functionality that would be found in the Scout code. Therefore it will not interface with the TCB. 

From your comments and questions I do think there is a large amount of basic programming knowledge that you would need to acquire first before it would be worth discussing specific firmware issues.

Does your Instructables project allow control via standard RC signals? If so, you might be able to use it with the TCB without any firmware changes since the TCB is also able to drive standard RC speed controllers, and you would have essentially built yourself a standard RC speed controller.

NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline Ncartmell

  • 19
    • View Profile
  • Poulton-Le-Fylde, Lancashire. UK
Re: Home Build
« Reply #34 on: February 21, 2019, 06:43:10 AM »
Hello Luke,

My plan was to only use the Modified Instructables code to test the UNO/Shield I have bought and also test the Scouts I made.

I also bought a Servo tester which proved the Scouts were faulty and not the Radio/TCB setup.

The Scouts perfom as expected with the Modified Instructables code.

My aim was to modify your code to work on the COTS UNO/Shield setup.

All I need to do is remove the Fan/Address/Thermistor sections from your code and re-allocate the pin assigments.

The pin assignment is done.

The code in GITHUB appears to have been split into different files and I assume needs putting back together into one file.

OpenPanzerScout.ino
FAN.ino
INPUT_RC.ino
INPUT_SERIAL.ino
SENSORS.ino
MOTOR.ino

If it works I will put the code in GITHUB (with your permission) so that other people who wish to use a SCOUT but cannot build one can go down the COTS route.

Best Regards

Neil

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #35 on: February 21, 2019, 02:09:36 PM »
Ok, it is more clear now. Yes I will be interested to hear if you can adapt the code for COTS use. If you do get it working, feel free to post it to GitHub, I will be interested to take a look at it. It may be possible to integrate the two versions into one with a flag being set to select which hardware it runs on (similar to the Rev 10 / Rev 11 flag).

Yes, the Arduino project is split into multiple files and no, they do not need to be combined.

The best way to edit the source is to clone the project from GitHub to your own computer, but if you are having challenges with Arduino 101 then I suspect it may not be worth learning the intricacies of GitHub of which even I am but a novice.

Alternatively just download the project (you can click the download button on the GitHub page, or go to the Open Panzer Downloads page and under the Scout Firmware section click "Download Zip"

Unzip the folder on your computer. At the root you will see two folders and some text files, for your purposes you only need the folder called "OpenPanzerScout." Copy that folder to your Arduino sketches directory (if you are unclear of where this is at, open Arduino, click the File menu, then Preferences, then look for the entry called "Sketchbook location").

After you copy that folder to your Sketches directory, double-click on any of the ".ino" files inside it and Arduino should open the project. Yes there are 7 distinct files, and Arduino will open all 7 and array them as tabs in your editor. Arduino knows to treat them as one project, but having multiple tabs is handy for organizing the code into various sections.
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline Ncartmell

  • 19
    • View Profile
  • Poulton-Le-Fylde, Lancashire. UK
Re: Home Build
« Reply #36 on: April 30, 2019, 06:49:27 AM »
Hello Luke,

It has been a while but I have slowly gone through the code and I have modified to suit the COTS installation.

Pin assignments changed, fresh values for Timer0 registers and code commented out.

It compiles ok and now needs checking.

However as part of doing the changes and with references to the 328 datasheet it appears that the best (highest) PWM frequency that can be achieved from Timer0 that will work with the VNH2SP30 chips is 4KHz.

I will see what happens.

If it does not work I have a plan "B", which involves cutting 4 tracks on the UNO board and adding 4 wires which will effectively re-wire the Timer1 pins to the Timer0 pins.
I have already changed the code to accomodate Plan "B".
This will bring it back into line with the SCOUT PWM output wiring.

Best Regards

Neil

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #37 on: April 30, 2019, 02:35:06 PM »
It's true. The Monster Moto Shield (and Chinese clones) route the two VNH2SP30 PWM lines to pins D5 and D6 on the UNO, which are mapped to the 8-bit Timer 0 on the ATmega328. The Scout hardware uses pins D9 and D10 which are mapped to the 16-bit Timer 1. The 16-bit timer allows us greater flexibility in the selection of PWM frequency. On the Scout the frequency is set to ~21KHz which is ultrasonic.

With the 8-bit Timer 0 you have fewer options but you can do better than 4KHz. I assume you derived 4KHz by using Phase-Correct PWM with a prescaler of 8 and a TOP value of 255 (the max that you can go with an 8-bit timer). However, you can use Fast PWM mode instead, again with a prescaler of 8 and a max TOP of 255 and you will end up with ~7.8KHz. That is still well within the range of human hearing but the motor whine will not be quite so annoying as 4KHz. I'll let you look at the datasheet and figure out the registers, but also make sure to change the MOTOR_PWM_TOP definition to 255.

Note that you will also have to change the function that translates the serial commands to speed commands, this is at the bottom of the INPUT_SERIAL tab. With the 16-bit Timer 1 we use a custom TOP value of 381 which we selected both because it gave us a perfect PWM frequency but also because it is exactly 3*127 and our speed signal comes in as a value from 0-127. So we multiply the incoming value by 3 and use that to set our pulse-width.

If you use an 8-bit timer with a max TOP of 255 you will have to scale the incoming value by 2 instead of 3.

Code: [Select]
int16_t getSpeedCommand_fromSerial(uint8_t val)
{
    // Serial speed commands should be 0 to 127.
    val = constrain(val, 0, 127);

    // MODIFIED VERSION FOR 8-BIT TIMER
    // Multiply by 2 to scale our speed value (from 0 to 127) to our PWM duty cycle range (0 to 255)
    if (val == 127) return 255;
    else            return val * 2;
}

As for RC the code will adjust automatically.

Anyway you are getting a good look under the hood, and it becomes clear why certain design decisions were made. I too looked at the motor shields early on but sadly the way they are wired is not ideal for our purposes.
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline Ncartmell

  • 19
    • View Profile
  • Poulton-Le-Fylde, Lancashire. UK
Re: Home Build
« Reply #38 on: May 02, 2019, 07:13:56 AM »
Hello Luke,

I did consider the FAST PWM but thought as you used Phase Correct I would stick with that.
Since you now mention using Fast PWM,  am I correct in assuming the Phase Corect was only chosen so that you could more precisely set the PWM frequency?

I noticed the Motor_PWM_Top definition but I have commented this out as you only seemed to use this for setting ICR1 and as this is not used with Timer0 and the value of TOP is predefined as 255.
Am I correct with this?

The multiplcation of the speed I did change to 2 but I am confused with the code you have shown.
I had changed the code as below

{
    // Serial speed commands should be 0 to 127.
    val = constrain(val, 0, 127);

    // Now multiply by 2 to scale our speed value (from 0 to 127) to our PWM duty cycle range (0 to 255)
    return val * 2;       
}


You have an extra line which is not in the code from Github and checks for the max value
if (val == 127) return 255;

Is it necessary?

It takes a while for me to understand code but I normally get there, however writing from scratch is a complete no no.

Going through all the routines is interesting as I am learning quite a bit.

Cheers

Best Regards

Neil

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #39 on: May 02, 2019, 05:11:21 PM »
Since you now mention using Fast PWM,  am I correct in assuming the Phase Corect was only chosen so that you could more precisely set the PWM frequency?
Yes that's correct. Either type of PWM will work fine for driving the motor but we can have different frequency options with each one. My goal was to get to 20Khz or above because the whiney-motor phenomenon really bothers me.


I noticed the Motor_PWM_Top definition but I have commented this out as you only seemed to use this for setting ICR1 and as this is not used with Timer0 and the value of TOP is predefined as 255.
Am I correct with this?
Actually MOTOR_PWM_TOP is also used in the function "getSpeedCommand_fromRC" on the INPUT_RC tab and your sketch shouldn't even compile if you commented out the definition, but maybe you have re-moved all the RC code I don't know. If you intend to leave the RC stuff in then you need to leave that defined (and set it to 255) because that is used to auto-scale the signal from the RC radio to an accurate PWM speed command.


The multiplcation of the speed I did change to 2 but I am confused with the code you have shown.
I had changed the code as below ...

You have an extra line which is not in the code from Github and checks for the max value
if (val == 127) return 255;

Is it necessary?
Right, I did add a little bit there. You can just multiply it by 2 as you have done, but note that 2*127 = 254 so you will never actually be able to get to full on which is 255. I doubt you'd notice it but that is why I threw in that extra line.

We didn't need to do any tricks like that in the stock code because I picked a custom TOP value that is exactly 3*127 (381). To do the equivalent thing here we'd want to pick a custom TOP value of 254 instead of 255, but when using the 8-bit Timer 0 the options for custom TOP values are not as convenient so just set it to the fixed value of 255 (WGM0 2:0 = 3, this requires setting bits in both TCCR0A and TCCR0B).

Actually, here is what I have for the new 8-bit setup, you can compare with yours and see if we match:
Code: [Select]
// TIMER 0 - MOTOR PWM
// ---------------------------------------------------------------------------------------------------------------------------------------------->   
    // We use Timer 0 to generate ~7.8KHz PWM on Arduino pins 5 & 6 (PD5 and PD6). Ken Shirriff has a good tutorial on the various types of PWM possible: http://www.righto.com/2009/07/secrets-of-arduino-pwm.html

    // We want:
    // - Waveform Generation Mode bits (WGM0 2:0) - split across TCCR0A and TCCR0B. These set the PWM modes, we want Mode 3 - Fast PWM with a fixed TOP value of 0xFF (255). See page 109
    // - Clock Select (CS0 2:0) - last three bits of TCCR0B which set the prescaler, we want prescaler of 8. See page 111.
    // - Compare Match Output A & B bits (COM0A, COM0B): Two bits each, in TCCR0A register, these enable/disable PWM on the associated pins. See page 107.
    //   The pins we are using are Arduino pins 5 & 6 or in other words, Atmega port D pin 5 and 6.
   
    // To control the duty cycle (set the motor speed), we write to OCR0A or OCR0B a value between 0-TOP (0-255)
    //OCR0A = 0-TOP;    // To set duty cycle on Arduino pin 6
    //OCR0B = 0-TOP;    // To set duty cycle on Arduino pin 5
   
    // The frequency is determined by the PWM mode (Fast PWM mode in our case), the clock frequency, the prescaler, and our TOP value.
    // Formula for Fast PWM is (Clock/Prescaler/TOP) = 16,000,000 / 8 / 255 = 7,843 Hz
    // Low frequencies result in "motor whine" which is annoying and doesn't sound realistic on a model. The VNH2SP30/VNH5019 motor drivers used on this device have a maximum PWM frequency input of 20Khz, though this
    // is not absolute. Higher frequencies cause less efficient operation and create more heat. Human hearing typically extends to about 20Khz, so above that the PWM should be inaudbile.
    // When using the 8-bit Timer 0 the best we can do is ~7.8KHz, which will still be audible but not terrible.
    // When controlled via serial the speed is passed as a 7-bit speed number (meaning values from 0-127), so we must multiply them by 2 to scale them to the PWM range of 0-255 for OCR0A and OCR0B.

    TCCR0A = 0xA3;              // COM0 A1:A0, COM0 B1:B0 = 10 (connect non-inverted PWM to pins), WGM0 2:0 = 011 (Mode 3, Fast PWM with TOP = 0xFF)
    TCCR0B = 0x02;              // CS1 2:0 = 010 (Prescaler = 8)
    TIFR0 =  0x07;              // Start off with all Timer 0 flags clear (by setting bits to 1 in TIFR0 register)
    TIMSK0 = 0x00;              // Disable Timer 0 interrupts (by clearing TIMSK0 bits). PWM is generated in hardware and we won't need interrupts enabled for it.
    TCNT0 = 0;                  // Reset TCNT0
    OCR0A = 0;                  // Start off with duty cycle for both motors at 0 for safety.
    OCR0B = 0;                  //


Note we won't be doing anything with ICR1 in this case, because TOP is fixed and anyway our 8-bit Timer 0 doesn't have a corresponding ICR0.


It takes a while for me to understand code but I normally get there, however writing from scratch is a complete no no.

Going through all the routines is interesting as I am learning quite a bit.
Frankly I learned everything I know from looking at what others had done, I don't have a degree or training in programming or electronics. Eventually you see enough you can put the pieces together yourself in new ways, and you also get pretty familiar with component data sheets, but still, the original foundation of everything came from somebody else. That's why open source is so great, none of us have to start from square one. Your project is a perfect example!
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline johnnyvd

  • 169
    • View Profile
  • Netherlands
Re: Home Build
« Reply #40 on: February 11, 2020, 04:07:44 PM »
Hey luke, i recently reflowed an older version of the Scout. Everything looks fine, but i'm not able to get bootloader/firmware installed.

I used an Arduino UNO as ISP to Burn the Bootloader to the Scout. ArduinoISP says "Done Burning Bootloader" with no further info.
But when i try to upload the firmware with a FTDI i get a "programmer not responding" error..:

avrdude : stk500_recv(): programmer is not responding
avrdude : stk500_getsync() attempt 1 of 10: not in sync: resp=0x3e


Also, no leds on the Scout are flashing.. I guess this is normal with only the bootloader on it?
Something wrong with my FTDI programmer? Or are there suspects on the board that could cause this?

Cheers, John
* E-75 / E-100 PAK44 "monster" - in progress
* Sturmjagdtiger PAK44 - in progress
* pz.kpfw KV-2 754(r) - in progress
* T-34 88mm "Kurland Tiger" - in progress

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #41 on: February 12, 2020, 04:25:32 AM »
If the bootloader process doesn't give an error then we would expect it has worked, though I seem to recall the confirmation being somewhat more verbose than you describe.

The bootloader is flashed using the 2x3 ICSP header so it is a different set of pins than the FTDI used for firmware. Therefore it is possible you could have a shorted pin on the latter that would prevent it from working, even though the ICSP pins are fine. The most probable place to check is on the processor itself, the legs are close together and sometimes there might be a bridge between them, try to look at it with a magnifying glass if you have one.

It's true that prior to loading the sketch the LEDs will not behave in the normal Scout manner, however, the red LED is connected to the same pin as the default LED on stock Arduinos, and this typically will blink even with only the bootloader, at the very least when first powered up, but I seem to recall it blinks at about a rate of once per second. So if the red LED does nothing at all it may be that the bootloader install was not successful.

I would go through the bootloader process again, making sure that you provide battery power to the Scout during the process, and making sure you have selected Arduino Nano as the target board.

It is also possible to load the sketch using the ICSP connection rather than FTDI, in the Arduino IDE go to Sketch -> Upload Using Programmer. This will over-write the bootloader if it is on there, so subsequent firmware loads will have to be done using the programmer unless you put the bootloader back on. But it might be something to try.

I suppose another possibility depending on where you got the ATmega 328P chips is that they could be counterfeits, this has been known to happen...
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline johnnyvd

  • 169
    • View Profile
  • Netherlands
Re: Home Build
« Reply #42 on: February 18, 2020, 01:46:38 PM »
Well, i tried to burn the bootloader several times, but my guess was that the Atmel was not genuine (well, i could not trace back the source).
I ordered several from Farnell so i have a trustworthy source. Also ordered some new SMD LED just to be sure that i have the specification of the cathode side.

Desoldered the old Atmel and soldered the new one back (hail the desoldering station!) and even desoldered an soldered the SMD Led's to check polarity..
Turned on verbose in ArduinoISP and burned the bootloader. Got some errors, but then with magnifying glasses it found some pins where not soldered right.

Second time Bootloader burning Logging say's everything went ok.. But no flashing leds? Maybe they burned out from reversed polarity?
Also i still get the same error when i try to flash the Firmware.. Still not responding..

Loading the sketch using the ICSP is not completely clear to me.. What sketch should i upload? Do you have a Firmware Sketch available?

* E-75 / E-100 PAK44 "monster" - in progress
* Sturmjagdtiger PAK44 - in progress
* pz.kpfw KV-2 754(r) - in progress
* T-34 88mm "Kurland Tiger" - in progress

*

Offline LukeZ

  • 1022
    • View Profile
  • France
Re: Home Build
« Reply #43 on: February 19, 2020, 06:59:14 AM »
Hi Johnny,

A few other things to check - when loading the firmware over FTDI, the Scout can not be connected via Serial to your TCB, otherwise it will fail. I should have mentioned this earlier. The Scout does need battery power during programming, but be sure to unplug the serial cable to the TCB during the programming operation. It won't damage anything if it is connected, but the programming won't work.

Also be sure to select the correct COM port for your FTDI adapter, and double-check that you are connecting your FTDI adapter in the correct orientation to the board. Out of curiosity what FTDI adapter are you using? These adapters can also be a source of problems, especially the Chinese ones. You may want to confirm the FTDI adapter itself is actually functional. 

Out of curiosity, I wonder also what ICSP programmer you are using to flash the bootloader?

As for loading the sketch using ICSP and the Arduino IDE, you can download the Sketch from GitHub, here is the link.

Click on the green "Clone or Download" button and select "Download ZIP." Unzip the file, there will be a few folders and files in there, you only need the "OpenPanzerScout" folder which you should place in your Arduino Sketch directory, wherever that is (you can find the location in the Arduino IDE by going to the File menu, selecting Preferences, and you will see the path to "Sketchbook Location" near the top of the popup form).

Now open this sketch in the IDE, select "Arduino Nano" for the board and select the correct Port. Now typically from here you would program the sketch on to your device using the right arrow button at the top of the IDE (via your FTDI adapter), but if you want to program the sketch using the programmer go to Sketch menu -> Upload Using Programmer (in this case you also of course need to specify what programmer you are using in the Tools menu, same as for doing the bootloader).

Let me know what happens...
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline johnnyvd

  • 169
    • View Profile
  • Netherlands
Re: Home Build
« Reply #44 on: February 20, 2020, 03:18:33 PM »
Hi Luke,

Thanks for your help. I got the Sketch loaded by using a Arduino UNO on ICSP. Red light, blue light. everything works..
Guess my FTDI adapter is a cheap copy.. Any suggestions on a good brand/type to buy?

Only problem i have now is that my M2 channel is not working like in one of the previous posts. It seems i have a short on the lower pads (i guess)..

Almost certainly the issue is a short on the motor driver chip M2 during reflow. This is not hard to do, and I have done it myself on occasion.

If i manage to remove the chip, is it still usable after the short?
* E-75 / E-100 PAK44 "monster" - in progress
* Sturmjagdtiger PAK44 - in progress
* pz.kpfw KV-2 754(r) - in progress
* T-34 88mm "Kurland Tiger" - in progress