The Association of Model Submariners.

Would you like to react to this message? Create an account in a few clicks or log in to continue.

* THE FORUM FOR ALL THOSE INTERESTED IN BUILDING AND OPERATING MODEL SUBMARINES *



Join the AMS - Registered Forum users can become members of the AMS and it's free ...... To join send an email with your name , address and phone number to amstreasure@googlemail.com


For a guide to past events see the "Shows and Events" section.
Bournville MBC on Sunday 11th August 2024, 10.00 i
::::

Papplewick Pumping Station Sub Weekend, 14th & !5th Sept 2024

P~~~

$$$

Who is online?

In total there are 3 users online :: 0 Registered, 0 Hidden and 3 Guests

None


Most users ever online was 180 on Tue Nov 05, 2019 6:03 am

Latest topics

» Robbe Seawolf V2
Arduino proportional control of a  piston tank EmptyYesterday at 3:52 pm by geofrancis

» ExpressLRS - 868/915 Mhz equipment
Arduino proportional control of a  piston tank EmptyFri Oct 11, 2024 8:58 pm by Marylandradiosailor

» Flight controllers as sub levelers
Arduino proportional control of a  piston tank EmptyFri Oct 11, 2024 8:14 pm by geofrancis

» 868/915 Mhz as a viable frequency for submarines.
Arduino proportional control of a  piston tank EmptyThu Oct 10, 2024 3:21 am by tsenecal

» Futaba -868/915mhz equipment
Arduino proportional control of a  piston tank EmptyThu Oct 10, 2024 3:15 am by tsenecal

» sonar data link
Arduino proportional control of a  piston tank EmptyMon Oct 07, 2024 12:53 pm by geofrancis

» Microgyro pitch controller corrosion
Arduino proportional control of a  piston tank EmptyWed Oct 02, 2024 11:32 am by geofrancis

» U Boat differential steering
Arduino proportional control of a  piston tank EmptyWed Oct 02, 2024 12:54 am by tsenecal

» WW2 mini sub build
Arduino proportional control of a  piston tank EmptyThu Sep 05, 2024 8:15 am by david f

Statistics

Our users have posted a total of 12526 messages in 1991 subjects

We have 1019 registered users

The newest registered user is Flyboy21

+4
salmon
C-3PO
tsenecal
timgarrod
8 posters

    Arduino proportional control of a piston tank

    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Arduino proportional control of a piston tank

    Post  david f Thu Dec 07, 2017 10:02 am

    Arduino proportional control of a  piston tank Image110

    Just done a bit more work on this inspired by Eric Weber's work on the SubCommittee Forum.

    Eric's hardware choice works nicely and it is ready built from an eBay supplier, so no need for a soldering iron!

    The software, as shown, works with a Hall Switch to count revs and has a failsafe. The piston tank is protected by limit switches - I prefer the separate circuit for this with diodes across the switches, as shown in Norbert Bruggen's book.

    I am quite a convert to the Arduino, by the way. My original routine using PICs took about a year to get going. This version on the Arduino - not much time spent over 2 months. It uses an Arduino Nano - my favourite.

    Some health warnings this version has only worked on the bench, so far, not yet in a model submarine. Use it at your own risk.

    A short video showing the controller working with a home made piston tank built for my Nordenfelt subs.

    https://www.youtube.com/watch?v=fFd_BKnzCe4&t=102s

    The software is best downloaded from my site on Github (my first attempts at this!):

    https://github.com/rdforrest/submarine-proportional-pistontank/blob/piston-tank/New_Piston4e.ino

    The sketch follows but you are best going to the Github:

    /*
    Proportional Piston Tank Controller by David Forrest based on work by Eric Weber and Gabriel Staples. 24/10/2017
     My code changes are labelled RDF. This version New_Piston4e (5/12/2017)
     Hall switch (A1104 from Allegro) used to count revolutions and give proportional control.
     An error signal is generated from the Hall switch count and the r/c input pulse.
     This is fed to the H bridge and motor (It is a servo really)
     When the unit is switched on it has 35 seconds to empty the piston tank and set the switch counter to zero.
     Loss of r/c signal (Failsafe) empties the piston tank and resets the switch counter.
     The Hall effect sensor is switched on when the south pole of a magnet comes close to the front tapering face of the sensor.
     Hall switch needs +5v supply.
     Nov 2017 Put pullup in software this seems to eliminate the need for a pullup resistor.
     Nov 2017 Built In LED now shows forward & reverse
     AnalogSmooth routine not actually used.

     Notes by Gabriel Staples
     Pulse_reader_w_pin_change_interrupt_singleCh.ino
     -read in any pulsing signal on Arduino pin INPUT_PIN (defined below), to get its period (us) & freq (Hz), with a time resolution of 0.5us
     --you can read in any pulse, including standard PWM signals, Radio Control (RC) PWM signals, etc.
     -I am using some low-level AVR code, which requires using some built-in Arduino macros to do pin-mapping.
     -this code only reads in a single channel at a time, though it could be expanded to read in signals on every Arduino pin, digital and analog, simultaneously.
     --this would be lots of work, so for now I'll leave that up to you.
     -this code should be able to read in any pulse between approximately 10~20us and 35.79 minutes; I'll let you experiment
     to find the actual shortest pulse you can measure with it

     By Gabriel Staples
     http://www.ElectricRCAircraftGuy.com/
     -My contact info is available by clicking the "Contact Me" tab at the top of my website.
     Written: 28 Nov. 2013
     Updated: 21 March 2015

     Some References:
     -to learn how to manipulate some of the low-level AVR code, pin change interrupts, etc, these links will help
     --http://www.gammon.com.au/interrupts
     --ATmega328 datasheet: http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf
     --http://playground.arduino.cc/Main/TimerPWMCheatsheet
     --See the *many* very helpful links at bottom of this article: http://www.electricrcaircraftguy.com/2014/01/the-power-of-arduino.html
     --reference the Arduino source code, ex:
     ---C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h
     ---C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c
     ---C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard\pins_arduino.h
    */

    /*
     Circuits:

     Option 1) To measure the pulses from an Arduino PWM pin, ex: pin 5 or 9, connect Pin 5 or 9 (a PWM output) to INPUT_PIN (the pulse reader input)
             -see the setup() function for commanding the PWM output to begin, so you can have something to read in

     Option 2) To measure an RC PWM servo-type signal coming from an RC Rx:
     -Power the Rx by connecting 5V to + on the Rx, and GND to - on the Rx
     -Connect the channel signal you want to measure on the Rx to the INPUT_PIN on the Arduino
    */

    #include <AnalogSmooth.h>

    /*
     Smooths signal jitter on analog inputs by averaging
     concurrent readings. The number of readings averaged can
     range from 1 (no smooting) to 100.

     The more readings you average the more consistent the signal
     becomes. At the same time it takes longer to detect actual
     changes in the signal.
    */

    #include <eRCaGuy_Timer2_Counter.h>

    //#include <avr/wdt.h>    // Include watch dog timer

    //macros
    #define fastDigitalRead(p_inputRegister, bitMask) ((*p_inputRegister & bitMask) ? HIGH : LOW)

    //Global Variables & defines
    const byte INPUT_PIN = A5; //RDF changed to A5 .you can change this to ANY digital or analog pin, ex: 10, 8, A0, A5, etc,
    //EXCEPT A6 and A7 (which exists on the Nano and Pro Mini, for example, and are NOT capable of digital operations)
    byte input_pin_bitMask;
    volatile byte* p_input_pin_register;

    //volatile variables for use in the ISR (Interrupt Service Routine)
    volatile boolean output_data = false; //the main loop will try to output data each time a new pulse comes in, which is when this gets set true
    volatile unsigned long pulseCounts = 0; //units of 0.5us; the input signal high pulse time
    volatile unsigned int pd = 0; //units of 0.5us; the pulse period (ie: time from start of high pulse to start of next high pulse)

    // Simple counter from below (RDF)

    int ip_pulse = 0;  // Variable from TX pulse by RDF

    int errsig = 0; // Error signal for servo action (Hall count minus PWM input)

    //https://quarkstream.wordpress.com/2009/12/11/arduino-4-counting-events/

    int state = LOW;

    int lastState = LOW;

    int count = 0;

    int reverse = 15;

    int failsafe_count = 1;

    //Digital input pin 8 for Hall switch input.

    unsigned long duration;

    int analog = errsig ;

    float analogSmooth;

    // Defaults to window size 10
    AnalogSmooth as = AnalogSmooth();

    // Window size can range from 1 - 100
    AnalogSmooth as100 = AnalogSmooth(100);


    void setup() {
     // put your setup code here, to run once:

     pinMode(8, INPUT_PULLUP);// Put Pullup on Hall switch input

     state = digitalRead(8);

     pinMode(INPUT_PIN, INPUT_PULLUP); //use INPUT_PULLUP to keep the pin from floating and jumping around when nothing is connected

     //configure timer2
     timer2.setup();

     //prepare for FAST digital reads on INPUT_PIN, by mapping to the input register (ex: PINB, PINC, or PIND), and creating a bitMask
     //using this method, I can do digital reads in approx. 0.148us/reading, rather than using digitalRead, which takes 4.623us/reading (31x speed increase)
     input_pin_bitMask = digitalPinToBitMask(INPUT_PIN);
     p_input_pin_register = portInputRegister(digitalPinToPort(INPUT_PIN));

     configurePinChangeInterrupts();

     //start PWM output (to read in its pulses, for use in Circuit 1 as described above)
     pinMode(5, OUTPUT);
     pinMode(9, OUTPUT);
     analogWrite(5, 10); http://976.5625Hz, with high pulses of ~1/976.5625 x 10/256 = 40us; Connect pin 5 to INPUT_PIN and open serial monitor & you will see approximately this
     analogWrite(9, 128); http://490.20Hz, with high pulses of ~1/490.2 x 128/256 = ~1020us; Connect pin 9 to INPUT_PIN and open serial monitor & you will see approximately this
     /*
       PWM Notes:
       -PWM on pins 5 & 6 occurs at 976.5625Hz; see here: http://playground.arduino.cc/Main/TimerPWMCheatsheet
       -PWM on pins 9 & 10 occurs at 490.20Hz
     */


     Serial.begin(9600);   //RDF changed from 115200
     Serial.print(F("Begin waiting for pulses on pin ")); Serial.print(INPUT_PIN);
     Serial.println(F(".\nData will be printed after each pulse is received."));

     // Test.connect motor controller pins to Arduino digital pins
     // motor one
     // https://tronixlabs.com.au/news/tutorial-l298n-dual-motor-controller-module-2a-and-arduino

     int enA = 3;
     int in1 = 2;
     int in2 = 4;

     // set all the motor control pins to outputs
     pinMode(enA, OUTPUT);
     pinMode(in1, OUTPUT);
     pinMode(in2, OUTPUT);

     //Test. This will be used for piston tank initial setup

     digitalWrite(in1, HIGH); //Swap in1 & in2 to reverse motor
     digitalWrite(in2, LOW);
     digitalWrite(enA, HIGH); //High runs motor

     delay(35000); //35 second delay to get piston tank empty from the start.

     //set rev counter to zero

     count = 0;

     // initialize digital pin LED_BUILTIN as an output.
     pinMode(LED_BUILTIN, OUTPUT);

     // Setup code finishes here
    }

    void loop() {
     // put your main code here, to run repeatedly:

     //local variables
     static float pulseTime = 0; //us; the most recent input signal high pulse time
     static float pd_us = 0; //us; the most recent input signal period between pulses
     static float pulseFreq = 0; //Hz, the most recent input signal pulse frequency

     if (output_data == true) //if a pulse just came in
     {
       //turn off interrupts, grab copies of volatile data, and re-enable interrupts
       noInterrupts();
       output_data = false; //reset
       unsigned long pulseCountsCopy = pulseCounts; http://0.5us units
       unsigned long pdCopy = pd; http://0.5us units
       interrupts();

       //do calculations
       pulseTime = pulseCountsCopy / 2.0; //us
       pd_us = pdCopy / 2.0; //us
       pulseFreq = 1000000.0 / pd_us; //Hz

       //failsafe_count = ++failsafe_count; //Increment failsafe count by RDF
       //if ( pulseTime > 1000 ) {
       //  failsafe_count = 0;  // set counter to zero if pulses are > 1000
       // }

       //print values
       //(optionally, add extra code here to not print after EVERY pulse is received, as this can result in serial data coming in excessively fast when pulses come in at a high freq)
       //Serial.print(F("pulsetime(us) = ")); Serial.print(pulseTime);
       //Serial.print(F(", pd_us(us) = ")); Serial.print(pd_us);
       //Serial.print(F(", pulseFreq(Hz) = ")); Serial.println(pulseFreq);

       Serial.print(F("  Hall Count=")); Serial.println(count);
       Serial.print(F("IP Pulse=")); Serial.print(ip_pulse);
       //Serial.print(F("Error signal = ")); Serial.print(errsig);
       //Serial.print(F("reverse = ")); Serial.print(reverse);
       //Serial.print(F("Failsafe = ")); Serial.print(failsafe_count);

       // Hall switch counter, with increment/decrement depending on direction of rotation by RDF

       int enA = 3;
       int in1 = 2;
       int in2 = 4;

       if (state == HIGH && lastState == LOW) {

         //  if (reverse > 0 ) { ++count; } else { --count; }
         if (reverse > 0 ) {
           --count;
         } else {
           ++count;
         }
       }

       lastState = state;

       state = digitalRead(8);
     }

     // Calculations here

     ip_pulse = (((pulseTime - 1005) / 7) - 20); // For a screw length of about 250 revs. 25 is stick trim factor

     //AnalogSmooth section not used and commented out

     //int analog = ip_pulse; // put ip_pulse into AnalogSmooth

     // Defaults to window size 10
     //AnalogSmooth as = AnalogSmooth();

     //int analogSmooth = as.smooth(analog);

     //ip_pulse = analogSmooth;

     errsig = count - ip_pulse;

     // Testing motor output pins

     int enA = 3;
     int in1 = 2;
     int in2 = 4;

     // If errsig is negative, reverse the motor

     if (errsig < 0) {
       digitalWrite(in1, LOW);   //Swap in1 & in2 to reverse motor
       digitalWrite(LED_BUILTIN, HIGH);   // turn the Built In LED on (HIGH is the voltage level)
       digitalWrite(in2, HIGH);
       digitalWrite(enA, HIGH);    //High runs motor
       reverse = -7;
     }

     // If absolute value of errsig is less than 20, stop the motor

     if ((errsig < 10) && (errsig > -10))
     {
       digitalWrite(in1, HIGH);   //Swap in1 & in2 to reverse motor
       digitalWrite(in2, LOW);
       digitalWrite(enA, LOW);    //High runs motor
       reverse = 2;
     }

     //Set motor to forward
     if (errsig > 0) {
       digitalWrite(in1, HIGH);   //Swap in1 & in2 to reverse motor
       digitalWrite(LED_BUILTIN, LOW);   // turn the Built In LED off(HIGH is the voltage level)
       digitalWrite(in2, LOW);
       digitalWrite(enA, HIGH);    //High runs motor
       reverse = 8;
     }

     // If Failsafe triggered - set piston to empty
     if ((pulseFreq > 53) || (pulseFreq < 49) && (failsafe_count > 1000))
     {

       failsafe_count = ++failsafe_count; //Increment failsafe count by RDF

     //Failsafe routine (like piston tank initial setup.)

     digitalWrite(in1, HIGH); //Swap in1 & in2 to reverse motor
     digitalWrite(in2, LOW);
     digitalWrite(enA, HIGH); //High runs motor

     delay(35000); //35 second delay to get piston tank empty.

     //set rev counter to zero

     count = 0;

       digitalWrite(in1, HIGH);   //Swap in1 & in2 to reverse motor
       digitalWrite(in2, LOW);
       digitalWrite(enA, HIGH);    //High runs motor
       Serial.print(F("Failsafe = ")); Serial.print(pulseFreq);
     }

     //else {failsafe_count  = 0;
     //}

    } //end of loop()

    ////Use macro instead
    //boolean fastDigitalRead(volatile byte* p_inputRegister,byte bitMask)
    //{
    //  return (*p_inputRegister & bitMask) ? HIGH : LOW;
    //}

    void pinChangeIntISR()
    {
     //local variables
     static boolean pin_state_new = LOW; //initialize
     static boolean pin_state_old = LOW; //initialize
     static unsigned long t_start = 0; //units of 0.5us
     static unsigned long t_start_old = 0; //units of 0.5us

     pin_state_new = fastDigitalRead(p_input_pin_register, input_pin_bitMask);
     if (pin_state_old != pin_state_new)
     {
       //if the pin state actualy changed, & it was not just noise lasting < ~2~4us
       pin_state_old = pin_state_new; //update the state
       if (pin_state_new == HIGH)

       {
         t_start = timer2.get_count(); http://0.5us units
         pd = t_start - t_start_old; http://0.5us units, the incoming pulse period
         t_start_old = t_start; http://0.5us units; update
       }
       else //pin_state_new == LOW
       {
         unsigned long t_end = timer2.get_count(); http://0.5us units
         pulseCounts = t_end - t_start; http://0.5us units
         output_data = true;
       }
     }
    }

    //Interrupt Service Routines (ISRs) for Pin Change Interrupts
    //see here: http://www.gammon.com.au/interrupts

    //PCINT0_vect is for pins D8 to D13
    ISR(PCINT0_vect)
    {
     pinChangeIntISR();
    }

    //PCINT1_vect is for pins A0 to A5
    ISR(PCINT1_vect)
    {
     pinChangeIntISR();
    }

    //PCINT2_vect is for pins D0 to D7
    ISR(PCINT2_vect)
    {
     pinChangeIntISR();
    }

    void configurePinChangeInterrupts()
    {
     //Pin Change Interrupt Configuration
     //see ATmega328 datasheet, ex: pgs. 73-75
     //also see: C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard\pins_arduino.h for the macros used here
     //1st, set flags on the proper Pin Change Mask Register (PCMSK)
     volatile byte* p_PCMSK = (volatile byte*)digitalPinToPCMSK(INPUT_PIN); //pointer to the proper PCMSK register
     *p_PCMSK = _BV(digitalPinToPCMSKbit(INPUT_PIN));
     //2nd, set flags in the Pin Change Interrupt Control Register (PCICR)
     volatile byte* p_PCICR = (volatile byte*)digitalPinToPCICR(INPUT_PIN); //pointer to PCICR
     *p_PCICR |= _BV(digitalPinToPCICRbit(INPUT_PIN));

     //  //ex: to use digital pin 8 as the INPUT_PIN:
     //  //turn on PCINT0_vect Pin Change Interrupts (for pins D8 to D13); see datasheet pg. 73-75.
     //  //1st, set flags on the proper Pin Change Mask Register
     //  PCMSK0 = 0b00000001; //here I am setting Bit0 to a 1, to mark pin D8's pin change register as on; for pin mapping see here: http://arduino.cc/en/Hacking/PinMapping168
     //  //2nd, set flags in the Pin Change Interrupt Control Register
     //  PCICR |= 0b00000001; //here I am turning on the pin change vector 0 interrupt, for PCINT0_vect, by setting the right-most bit to a 1
    }
    avatar
    timgarrod
    AMS Website Webmaster


    Posts : 260
    Join date : 2013-04-23
    Age : 44

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  timgarrod Thu Dec 07, 2017 5:58 pm

    Cheers David,

    this was something i was planning to do but wasn't sure were to start.

    Cheers

    Tim
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Fri Dec 08, 2017 4:38 am

    looks very good... would it be possible to have a list of parts? I liked the youtube video as well... seems nice and stable, no "hunting" once the piston position is matched to the stick position.
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Fri Dec 08, 2017 9:20 am

    For hardware details I'm best just quoting Eric's words over on the SubCommittee:

    "Here is what you need:
    1x Arduino Nano Board - ~2 USD
    (purchase of ebay. Example: http://www.ebay.com/itm/1-2-5-10PCS-...o/282228063941 )

    Motor Speed Controller:


    Option 1 – H-Bridge (use the first code sample and wiring diagram below) – NOTE: current is limited with the below module to 2A. My tank pulled more amps so I want with the ESC instead.
    1x H-Bridge – L298N - ~2 USD
    (purchase of ebay. Example: http://www.ebay.com/itm/Stepper-Moto...o/170926726867 )"

    His full thread is here:

    http://subcommittee.com/forum/showthread.php?37060-DIY-Piston-Tank-Controller-with-an-Arduino-Board

    There are not many other bits. The Allegro Hall switch (A1104 ) I got on eBay. I have a couple of ordinary diodes (but 10amp!) wired across the microswitches.

    You make an interesting point Tim T about the lack of "hunting".

    I used a 40Mhz receiver for most of the trials because it is more prone to interference and "glitching" than a 458 one.

    All the software has is a "deadband" of  +/- 10 counts. The original pic software had a low speed approach to the set point and a few other things as well.

    They are not really necessary as long as you have a fairly slow geared motor. The tank in the video uses a 30:1 geared motor. This also keeps the current down. (less than 0.2 amps for the one in the video)

    A slow speed tank is OK with proportional control, I think. You just set the stick and go and do something else.

    I really like piston tanks but the thing that still holds them back is making them. Probably impossible without a lathe.

    Many thanks for the interest!

    David
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Fri Dec 08, 2017 5:23 pm

    eric's words on subcommittee ring absent in my case.... even though i have an account on their forum, i am not a member of the subcommittee, and that thread is in their restricted "private" area, accessible to members only.

    that also explains why i never saw the original posting on subcommittee when it was first posted...
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Wed Aug 15, 2018 2:26 pm

    Tim G pointed me towards one of these:

    Arduino proportional control of a  piston tank S-l40010

    They are very cheap (about £5) and easily available. They are quite a beast in their specification - purportedly being able to switch 43 Amps. That would be a very large piston tank or a "Robot Wars" type of servo!

    This photo shows the two Arduino proportional piston tank controllers. The original (2 Amps, I think) on the L.H.S and the new one on the right. Similar footprint but deeper to include a large heat sink.

    Arduino proportional control of a  piston tank 20180812

    The H bridge doesn't come with any instructions (what can you expect for a fiver?) and the pinouts are a little confusing, but to use it as an H bridge for a single motor you do the following: (I have extracted this from the comments section of the software I have just put up on GitHub. (There is no change to the actual software, Arduino pins etc.):

    Semiconductor Motor Driver Auto BTS7960 43A H-Bridge PWM Drive For Arduino BF

    // Summary of pin connections when using IBT-2 Double BTS7960 H-bridge by RDF
    //On Arduino Nano:
    // A5 to receiver output
    // D8 to Hall switch counter
    //On IBT-2 Double BTS7960 H-bridge:
    // Connect pin 7 to +5v on Arduino
    // Connect pins 3 & 4 together and connect to D3 on Nano (These pins turn the motor on)
    //Connect pin 1 to D4 on Nano (These pins set the direction of rotation of the motor.)
    //Connect pin 2 to D2 on Nano ( These pins set the direction of rotation of the motor.)


    Some health warnings: I haven't used this software or hardware in the wet in a submarine yet. (I still use the original H bridge boards with John Robinson's additions controlled by a PIC processor. They just "work" in all my subs.)

    But nowadays, it is so much easier and cheaper for someone to simply buy one of these IBT-2 boards and control it with an Arduino.

    I will be taking both boards to Haydock Park (and a couple of Tom C's electric torpedoes) if any one wants to see them.

    David


    Last edited by david f on Thu Aug 16, 2018 10:04 am; edited 3 times in total
    avatar
    timgarrod
    AMS Website Webmaster


    Posts : 260
    Join date : 2013-04-23
    Age : 44

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  timgarrod Wed Aug 15, 2018 6:24 pm

    How did you find these.

    I designing a twin version for my gato but works the same as the Tmax board.
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Thu Aug 16, 2018 10:00 am

    Well I have only tried it on the bench, so far, and I certainly haven't put 43 Amps through it!

    Seems very rugged (these modern ones seem to have much better electronic protection on them - those are the things that John R added) and it is not much bigger than the 2 amp ones so I think they should be the starting point for anyone. (And I still can't believe its only £5)

    David


    avatar
    timgarrod
    AMS Website Webmaster


    Posts : 260
    Join date : 2013-04-23
    Age : 44

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  timgarrod Thu Aug 16, 2018 9:09 pm

    thats good to know, will order a couple and have a play. still need to convert the two piston tanks to have a linear pot.
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Sep 11, 2018 3:32 pm

    David,

    i finally got around to testing this code, and it will not compile...

    #include <AnalogSmooth.h>

    #include <eRCaGuy_Timer2_Counter.h>

    these are two libraries that are not standard..... can you provide links to them?
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Tue Sep 18, 2018 1:21 pm

    Hi Tim,

    Thanks for pointing these problems out.
    I have uploaded a modified version of the sketch to Github:

    Piston_4g
    https://github.com/rdforrest/submarine-proportional-pistontank/blob/master/Piston_4g.ino

    What I have done is remove all reference to AnalogSmooth (I didn't use it anyway.)

    The details for Gabriel Staples are below: (copied from the sketch)

    "By Gabriel Staples
     http://www.ElectricRCAircraftGuy.com/
     -My contact info is available by clicking the "Contact Me" tab at the top of my website.
     Written: 28 Nov. 2013
     Updated: 21 March 2015
     http://www.electricrcaircraftguy.com/2014/02/Timer2Counter-more-precise-Arduino-micros-function.html
     David Forrest note: Seems to need $5 donation now(18/9/2018)
     https://github.com/ElectricRCAircraftGuy/eRCaGuy_Timer2_Counter
    "

    He does seem to need a $5 donation now. (I don't remember that when I started on this!)

    I am still finding out about the Arduino and libraries!

    Hope this works OK now. (I have just checked and the same sketch works for both the low current H bridge and the 43A beast! (I would go with the beast, it is only slightly bigger physically)

    Probably best to point out that is only bench tested not "in the wet"as yet. (My winter project after I get Tom's torpedoes running straight and hot!)

    David
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Sep 18, 2018 3:23 pm

    I am going to do a little more research on this...

    after i posted the reply to you about the two different libraries, i did find a github repository with an older version of the eRCaGuy_Timer2_Counter library available for free.

    it appears the reason for the eRCaGuy_Timer2_Counter library is that it provides a much nicer, less "jittery" calculation for the receiver PWM signal coming into the arduino. in my code that i use on things like my robbe multi-prop decoder, i simply use the standard microseconds call.

    what i have found is the eRCaGuy_Timer2_Counter library only works on atmega 328p processors, commonly found in arduino mini and nano devices and clones. i primarily use the atmega 32u4 based sparkfun pro micro clones... the free version of the eRCaGuy_Timer2_Counter library will not compile on the pro micro clones...

    the reason this guy wrote his library is because the standard micros "system" call is shut off when interrupts are disabled, so the micros call is not guaranteed to be 100% accurate. you can see in the code, the disable/enable interrupts call is being used in the main loop when the "pulseCountsCopy" variable is being set. granted inside that block, two variables are being set, so not alot of time is spent there, but if we can remove it, micros might work well enough. I will keep you posted on what i find.
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Mon Feb 18, 2019 10:38 am

    A bit more hardware choice for the "Tims" and others interested.

    Arduino proportional control of a  piston tank 20190210

    The photo shows the complete trio of easily available (ebay etc) H bridges used for proportional control using the Arduino.

    They range in current capacity from the (latest trial) at ) 0.6Amps to the 43 Amp one on the RHS.

    The left hand one is:

    Mini Motor Drive Shield Expansion Board L293D Module For Arduino UNO MEGA. Available for £3.90 in the UK (Half that if ordered from China)

    This is destined for a ballast shifting screw jack for my CSS Pioneer as the geared motor and screwed rod indicate.

    So not for a piston tank but the same software and Arduinos work in all 3.

    How are you getting on with the software Tim S ? I had a recent problem using my Nano clones when they stopped programming. It turned out that the Arduino bootloader has been updated. The latest IDE version 1.8.8 has the option to revert to the old bootloader.  Micros are endlessly fascinating and annoying!

    David
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Feb 19, 2019 12:30 am

    David,

    not looked into the arduino 32u4 code changes, there basically aren't any.  that cpu doesn't have a timer2, so nothing can be done.   what i have done,  is moved on to another platform.  still using the arduino IDE,  since it is so simple to setup and use, but i have moved to the STM32 family of chips.  you can get boards similar in size to the mini arduino family of boards, but with 6x to 12x the horsepower, for $2 to $12 from china.   they are also much more capable and easier to setup with things like timers and interrupts...  i am all for anything that reduces complexity.

    a sample of what i am talking about:
    https://www.ebay.com/itm/5X-STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-for-Arduino/202000920130?epid=12025202800&hash=item2f08316e42:g:KC0AAOSwcYZZe03k:rk:2🇵🇫0

    it is $15.00, but that is for 5 of them, so $3.00 a piece.  I am currently prototyping an 8 channel pistol radio with one.

    Arduino proportional control of a  piston tank Blue_p10
    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  C-3PO Tue Feb 19, 2019 9:22 am

    Hi Tim,

    Are the logic pins on those boards 5v tolerant?
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Feb 19, 2019 4:03 pm

    C-3PO wrote:Hi Tim,

    Are the logic pins on those boards 5v tolerant?


    the best way to answer that is with a graphic of the board's pinouts... as you can see from the legend, most of the digital pins are 5v tolerant, but most of the analog pins are not.

    Arduino proportional control of a  piston tank Blue_p11
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Feb 19, 2019 4:06 pm

    to be honest, i don't really have a problem with the stm32 microprocessors being 3.3v. most of the things i am connecting to are actually 3.3v, and needed logic shifting to work with the 5v arduinos... shifting to the stm32 devices allowed me to remove that need.
    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  C-3PO Tue Feb 19, 2019 4:13 pm

    Thanks for info. I am still suffering the pain of both 3.3&5V and the lovely level shifters

    Looks like we can get them in the UK for £10.20 for 5 post free UK stock

    My goto is still Teensy and in particular 3.5 or 3.6 but I'll order some as it's another thing to play with

    Thanks for info...

    Jonathan
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Feb 19, 2019 9:21 pm

    i know of the wonderful teensy tools, and own at least one of the teensy 3.2, but they are at least three times as much money compared to the cheap chinese clones... depending upon which model you are looking at...

    teensy 3.1/3.2 (@ $20) compares to the "blue pill" @ $3

    teensy 3.5/3.6 (@ $35) compares to the "stm32F407vet mini" @ $12 or similar slightly larger boards costing $10

    https://www.ebay.com/itm/Mini-core-board-STM32-minimum-system-version-STM32F407VET6/182309828654?hash=item2a7283382e:g:SecAAOSwnNBXXpV5:rk:1🇵🇫0

    i picked up a couple of the blue pills to try out, using them to test out theories for a Pistol style R/C transmitter, and then picked up the mini for the brains of a monster best of all worlds transmitter that does everything for all my models in one box, once i figure out what that means, based on the work put in for the pistol radio...
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Tue Feb 19, 2019 9:27 pm

    I have ordered one of these as a replacement for the pro micro arduino clone that i like. this one appears to be 3mm wider and basically the same length as the pro micro.

    when it arrives, i will be attempting to run David's proportional ballast tank sketch on it, hoping to have zero issues converting the code to run on it.

    https://www.ebay.com/itm/STM32F103TB-ARM-Cortex-M3-Development-Board/172251930064?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  C-3PO Wed Feb 20, 2019 8:24 am

    I take a slightly different view when putting tech into a model thats cost hundreds/thousands in both time and money.

    I would prefer to spend money on the "real deal" rather than any clone in the hope (naive?) that it will be relaible (do what is supposed to do) and pay me back in terms of less grey hairs.

    I purchased 25 Nano clones a while back and I have at least 4 that didn't make the grade from the batch.

    Plus the Teensy 3.5 - 120 MHz ARM Cortex-M4 or Teensy 3.6 32 bit 180 MHz ARM Cortex-M4 processor is worth it's weight in gold I think (also includes SD card slot)

    I had an application that had multiple sub systems that the other boards I used just could not keep up with (was always dropping GPS data) - the Teensy no surprise cruised through it.

    Also nice to have "real" serial ports

    In summary I would counsel anybody using a "cheap clone" in a high cost model - it's all right until it's not

    Just my pennies worth :)

    C-3PO
    david f
    david f
    AMS Treasurer


    Posts : 2411
    Join date : 2010-11-10
    Age : 74
    Location : Cumbria

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  david f Wed Feb 20, 2019 10:28 am

    Arduino proportional control of a  piston tank 20190211


    That's funny. I must have anticipated your post C-3PO!

    My genuine Nano arrived in the post this morning. Proof above!

    David

    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  C-3PO Wed Feb 20, 2019 10:38 am

    David - Timing sometimes a funny thing

    I just checked eBay - last purchase £51.80 for 20 Nano clones to repurchase now £62

    Bet that pretty cardboard box was a couple of pounds itself :)

    Despite the failure rate I experienced they were good for what I used them for.

    Recently I have had some logic level convertors that were less than satisfactory - the solder pad circles where you attach a header were bady formed and virutally NO metal to solder onto!!

    My real point as we all know is that sometimes spending a few more pounds is worth it in the long run - The quality of PJRC Teensy boards speak for themselves

    C-3PO
    avatar
    tsenecal
    Guest


    Posts : 321
    Join date : 2015-04-01

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  tsenecal Thu Feb 21, 2019 2:35 am

    C-3PO,

    not sure i agree with you 100%, especially in the modern era, where everything appears to be made in the same Chinese factory... with only a few exceptions.

    all things have limitations and "errata"... i will admit that the Teensy family of devices is nice, but i have not had the bad luck with the little boards you have had. every single one has worked, whether it was a "name brand" or not. to me, we are dealing with a hobby, not military grade hardware, and to me, my hobby is the last item on my list of where my money goes, so if i can buy 3 chinese stm32f4 boards instead of one Teensy, then i will be buying the chinese boards. interesting note about arduino... the schematics are open source, so technically the "clones" aren't really clones.
    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Arduino proportional control of a  piston tank Empty Re: Arduino proportional control of a piston tank

    Post  C-3PO Thu Feb 21, 2019 12:53 pm

    Tim you raise an intertesting point re "clones"

    I read up about the development history evolution of "Arduino" a while back and it appears that the water is somewhat muddied and depending who's view point is being expressed the story is quite different - hence the Genuino. I can't remember the detail but the name Uno/ Nano etc should only be used I think for the real deal original - open source manufacturese are supposed to rename their products e.g. SeedUino

    Don't want to get hung up on this but my understanding is that there are real open source ventures ("Deek Robot")  that produce their own boards and seem to be of a fairly good quality and then there are  copies (clones) which even carry the Arduino/Genuino logo and proport to be the originals and are quite often of a less quality construction. - I guess "caveat emptor"

    I reckon I have purchased 70 plus boards of various types Uno/Nano/Mega/Due/ etc and the quality of some was awful - couldn't even solder the header strips as the solder would not flow on the board

    C-3PO

      Current date/time is Sun Oct 13, 2024 11:29 pm