* 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 register on the forum first then follow the forum link to our membership form which is on our website


For further details of any events shown here also see the "Shows and Events" section on the forum

Let us know of your plans for 2018 and we will promote them on this Forum

.

, Papplewick Pumping Station Easter Sunday & Monday 1,2 April 2018

.

. .

.Norwich MBC Weekend 28,29 July 2018

.

.

,The Model Show,Poynton, Stockport (with swimming pool) 15,16th September 2018

Who is online?

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

None


Most users ever online was 37 on Sun Mar 13, 2011 11:27 am

Statistics

Our users have posted a total of 10398 messages in 1691 subjects

We have 739 registered users

The newest registered user is paulstel


    PIC and Arduino microprocessors

    Share
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Sat Mar 14, 2015 9:01 am

    THANK YOU , THANK YOU JON

    MARIUS
    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Mon Mar 16, 2015 8:50 am

    Good tip!

    I have found those gooligum tutorials very good. Well written and not too complicated.
    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Thu Nov 05, 2015 3:27 pm

    Well autumn and winter is settling in and (as planned) I'm heading back to have  a look at microprocessors.

    I've bought myself a couple of Arduino Nanos (partly with an eye on John Ws work on making an easy, cheap openLRS TX).

    I've just been trying some of the examples and I'm very impressed!

    -The software is easy to download and use.
    -The hardware (Nanos) all work straight out of the box.
    - The examples are very clear and seem to work well.

    So far I've tried the encoder software by Phil Green, the analogue voltage indicator and of course the flashing LED!

    Next to try is a 16x2 LCD.

    I may just be thinking of changing from PICs (I've changed the overall title of this thread.) PICs are fiddly things to connect up and get communicating. Maybe the Arduino is better for we part-time amateurs?
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Thu Nov 05, 2015 8:08 pm

    HI DAVID ,
    Great news .
    I practiced some exercises with Arduino UNO .
    At the beginning everything Went well and I made rapid progress , but as I progressed , affairs were complicated and unless you have serious knowledge in programming You do not succeed much .

    Actually I get stuck when I tried to program The  famous 16 x 2 LCD  ... so if you want to share from what You've managed to do with that would be great .
    All I get from that LCD was to show me "Hello World" and that's it .

    I wanted to do at the end a thermometer / barometer with Clock and Date using the RTC DS1307 / DHT11-22 and the LED 16x2 and from here to use him on diffrent aplications .

    Good luck and Manny Thanks in advance .
    PLEASE keep us on post about Your work .

    MARIUS
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Thu Nov 05, 2015 8:21 pm

    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Fri Nov 06, 2015 2:16 pm

    Hello Marius!

    Nice videos and you make some very good suggestions - so a "steep learning curve".

    I suspect the problem comes when you try to combine libraries in a single sketch. Probably no substitute for a basic grounding in C. (It would be nice to know how others have got on with the Arduino.)

    I will let you know how I get on with the LCD.

    David
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Fri Nov 06, 2015 6:22 pm

    THANK YOU DAVID .

    MARIUS

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Fri Nov 06, 2015 7:52 pm

    david & marius,

    i have spent a little time lately making two different objects using arduinos.

    1) a ballast tank controller

    2) a sensor "hub"

    the sensor hub has 2 temperature sensors, one voltage sensor, one amperage sensor, a compass, x tilt, y tilt, and depth sensor, and sends the data back to the transmitter by "faking" the data for a "D" series frsky hub, and sending it back through the 433mhz receiver/transmitter module to a Taranis transmitter display.

    david hit the nail on the head. i was limited to a specific set of arduino boards due to the i2c and serial and usb libraries i needed to use to get all the sensors working together, and sending data to the receiver.

    the same thing is limiting what boards i can use with the ballast tank controller, i need to be able to read a specific channel from the receiver, read a pressure sensor, count interrupts from a hall sensor, read two on/off switches, and send servo signals to a speed controller. using the available interrupts without having libraries step on each other limited which boards could be used for that as well. I am hoping to be able to use the same pressure sensor data that the smart ballast controller is using to verify depth as data to be sent back to the transmitter as telemetry, but if the telemetry library interferes, it will be tossed.

    i find that any library that uses timers or interrupts or serial ports will probably interfere with at least one other library....

    Tim
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Sun Nov 08, 2015 4:21 pm

    Hy @tsenecal ,

    THANK You for that complex answer !.
    But for me is WAY TOO much ...LOL , ....and I can't even say the Famous replica " English Please" ... LOL ,

    My knowledge in programming with this new invention - Arduino and with programming in general are extremely limited , and You have to imagine that a I am child hoo is just learning to barely crawl away ..... and wheel take long time until get to stand up and talk .
    So for me what are you say is like that Chinese ... LOL .

    If You have time to explain litle by litle about each one of those devices : "...temperature sensors, one voltage sensor, one amperage sensor, a compass, x tilt, y tilt, and depth sensor..." about how did You make them interract with Arduino is great , if Not is OK .

    Actualy I am interested to see and understand how did You made the "ballast tank contoller " first , and then step by step If there is anought time the other things .

    THANK YOU and All the Best

    MARIUS

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Mon Nov 09, 2015 12:32 am

    Marius,

    i understand your need to crawl before you can walk. my livelyhood is computer programming, and i have been doing it for 35 years, plus 4 years of college education. programming the arduino takes me back to those very early days, the programming can be very easy, but also very frustrating.

    the only real info you need to understand from my overly detailed reply is that i have two separate arduino gadgets being built. they both require using all kinds of sensors, and different sensors communicate with the arduino in different ways. some very simple, some not.

    the big problem with arduino is that a lot of the extended functionality comes from libraries. code that other people have written, and you can use as if it is part of your program. they wrote it for themselves, and use it by itself. it works fine until you try to use it with another library that some one else ( a third person ) wrote, completely independently from you and the person that wrote the first library. it may use some of the same basic functionality (timers, or interrupts) as the first library, causing a conflict. add to that, different models of arduino have different capabilities. software that runs perfectly fine on one type of arduino might fail completely on a different type of arduino.

    as to the rest of the questions about how i did a specific thing, I plan to do exactly that. i want to document exactly how i built the arduino device that sends the telemetry data from the submarine back to my Taranis, including the code i wrote to do it. the ballast tank controller will come after that.
    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Mon Nov 09, 2015 2:00 pm

    Hi Both,

    I still seem to be on a roll with this Arduino, good progress and I only got them on November 5th. (And I'm still leading a normal life - eating, talking, watching TV etc.!)

    The best advice, is always to have a problem you REALLY want to solve otherwise you give up at the start of the  steep learning curve.

    In my case, the problems were solved some years ago - a lipo voltage monitor  and a proportional piston tank controller so this reduces my motivation a bit. These work on PICs and were written in assembler. They did take weeks and months to write and test so I am interested to see if the Arduino makes it quicker and easier.

    First up was the voltage monitor. I used the ReadVoltageMonitor sketch from the Basic examples. I liked the Serial Monitor to put output on your computer screen (In Tools) since it made the Arduino very "talkative" unlike PICs. (I am not going to bother with the LCD yet, as a result.) You would need to put some hardware on this setup - voltage divider etc. It would need voltage alarms triggered in software but that is not too hard - some > functions.

    Next up was to try to combine software for a counter (input from a Hall Switch ) combined with software to measure pwm output from a receiver. These are the inputs needed to do proportional control of a piston tank.

    These went together very easily (see below - but it is a prototype.) and will print a count and a pulse length in millisecs on your computer screen. It will need a lot more work to give a motor on, motor reverse signal for a H Bridge motor switcher but it came together impressively quickly. PulseIn is very powerful and would be immediately very useful as a transmitter + receiver tester.

    On the downside, I suspect that this simple routine would make excessive demands on processor time ( The Hall switch counter routine could do with being interrupt triggered.)

    I've also blown up one of my 2 Nanos - but they will hardly break the bank.

    I still like the comparison of the Arduino with Fast Food though - if it is just what you want at the time, go for it , but don't expect too much!



    // Simple counter from below (David F) combined with pulsein for pwm input

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

    int state = LOW;

    int lastState = LOW;

    int count = 0;

    int pin = 7; // input digital pin for pwm input. Digital input pin 8 for Hall switch input.

    unsigned long duration;

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

     Serial.begin(9600);

     pinMode(pin, INPUT);

     pinMode(8, INPUT);

     state = digitalRead(8);
    }

    void loop() {
     // put your main code here, to run repeatedly:
     if (state == HIGH && lastState == LOW) {

       count++;

       Serial.println(count);
       Serial.println(duration);
     }

     lastState = state;

     state = digitalRead(8);

     //PWM measurement (DF)
     duration = pulseIn(pin, HIGH);
    }
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Mon Nov 09, 2015 3:45 pm

    THANK YOU @tsenecal ,

    I understand the complexity of the Programming and for know all I want , is to read all the explanations from the forum , watch the tutorials on YouTube and in time to follow some example .
    I looking forward to see what's next .

    Thank You for Your time .

    MARIUS

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Mon Nov 09, 2015 5:31 pm

    David,

    everyone seems to start with the pulsein to read pwm from the receiver.

    that is bad form.

    pulsein is a blocking api call, therefore the Arduino can't do anything else while waiting for the pwm signal to change... which is very bad form if you are waiting for something like a hall sensor or a switch to be triggered... say to keep a piston from driving into the dry space of a submarine...


    there is a very good blog that i found, and is the foundation of all my servo and receiver code:

    http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html

    the author of the blog basically uses interrupts for everything, and counts milliseconds to see how long the PWM pulse was.

    you will want to use interrupts for the hall sensor as well, and that is where things start to get tricky. if your arduino only has 2 interrupts,

    and you are using one for the receiver, and one for the hall sensor... what do you use for the 2 end limiter switches? most serial port libraries also use interrupts...


    Arduiono does have a very nice servo library, that makes sending pulses to a servo or ESC very easy... which is what i used for my ballast tank controller.
    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Tue Nov 10, 2015 9:59 am

    Hi Tim,

    Yes, I take your point about pulseIn.

    I suppose it is commonly used because it is very simple to use and interrupts can be tricky.

    (It must have applications in systems which are not very processor intensive e.g a servo tester. A piston tank is not that busy either and it occurs to me that my piston tank controller written in assembler works well. That uses an interrupt on the Hall input but the pwm input uses a basic polling routine by Ken Hewitt

    http://www.theassociationofmodelsubmariners.com/t375-pic-and-arduino-microprocessors

    I wonder if the fact that it is in assembler helps? Quicker routines compared with software written in C??)

    We had a discussion on here some years ago about the use of limit switches and we decided against the use of them included in the software. So I use microswitches and diodes in the motor supply line (as shown in Norbert Bruggen's book)

    I think that this is probably the right approach. When faced with a fault that could tear your piston tank apart and sink your sub, it may be best to use a separate control system!

    Many thanks for the excellent link on r/c for the Arduino. That is the way to go.

    David

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Tue Nov 10, 2015 6:11 pm

    David,

    this is turning out to be quite the educational thread...

    yep, i think 99% of the people out there use pulsein because it is a single api call, instead of 20 lines of code in three separate areas of the program.

    i understand the use of limit switches as mechanical devices, but by me being stubborn about the brushless motors, one cant cut the circuit with a NO switch cleverly placed in the wiring to the motor, or at least my brain isn't big enough to figure out how to do it, so for me, it is necessary that i use them in software.

    having said all that, i am still only at the testing stage of my ballast tank.  I did, however, get my "hub" tested and working reliably, and consider it to be at a stage where it is "usable"...  but haven't yet decided if it is "useful"...  when running the sub, it isn't always wise to take your eyes off the sub to stare at a little screen.

    the other side of all this code that a lot of people ignore, is how to configure the device. I foresee the ballast tank controller working for both piston and pump/bag style ballast tanks, as well as different size tanks, etc. i see some simple USB communication in my future.

    the joys of having such an insane hobby...
    avatar
    salmon
    AMS Forum Owner

    Posts : 259
    Join date : 2011-09-02
    Age : 57
    Location : Las Vegas, Nevada - USA

    Re: PIC and Arduino microprocessors

    Post  salmon on Wed Nov 11, 2015 2:48 am

    Tim,
    Being a mad scientist helps too!
    Peace,
    Tom


    _________________
    If you can cut, drill, saw, hit things and swear a lot, you're well on the way to building a working model sub.
    avatar
    John Wrennall
    AMS member

    Posts : 157
    Join date : 2011-11-16
    Age : 71
    Location : Leyland

    Re: PIC and Arduino microprocessors

    Post  John Wrennall on Wed Nov 11, 2015 1:40 pm

    Hi all.

    For anyone doing development work on an Arduino Nano, in lieu of a solderless breadboard it is worth considering a Funduino Expansion board.

    http://www.banggood.com/Multi-Function-Funduino-Nano-Shield-Nano-Sensor-Expansion-Board-p-91852.html

    A handful of servo type leads to connect your sensors and a 5V supply and what could be easier...

    John
    avatar
    david f
    AMS Treasurer

    Posts : 1920
    Join date : 2010-11-10
    Age : 67
    Location : Cumbria

    Re: PIC and Arduino microprocessors

    Post  david f on Thu Nov 12, 2015 10:40 am

    Hi John,

    That's the one suggested for the TX encoder Arduino is it not? (In which case I have one on order.)

    And Tim. I now understand the need for so many interrupts - you are going to use a brushless motor! I have only ever used brushed motors in piston tanks, so far - partly because of availability and gearboxes etc. (I use the MFA ones.)

    However I am very enthusiastic about the use of brushless propulsion motors now. (More on this shortly)

    David
    avatar
    John Wrennall
    AMS member

    Posts : 157
    Join date : 2011-11-16
    Age : 71
    Location : Leyland

    Re: PIC and Arduino microprocessors

    Post  John Wrennall on Thu Nov 12, 2015 4:47 pm


    Just a thought but has anyone considered using stepper motors for a piston tank.?

    It should be relatively easy to control with something like an arduino, probably no limit switches needed, distinct steps to different depth stages.

    Can anyone comment on the available torque compared with the normal motor and gearbox combination?

    John
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Thu Nov 12, 2015 5:41 pm

    I think it is a good idea.
    They are powerful and most of all precise .
    But I don't know if you are made so small as brushed motors and don't know which is the lowest voltage to power them and current consumption .

    That's just my opinion. I don't know much about these motors .
    I have seen they becom used in more and more various applications .  

    MARIUS

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Fri Nov 13, 2015 5:58 pm

    tried both a nema 11 and nema 14 size stepper motor on the test ballast tank.

    http://www.omc-stepperonline.com/nema-11-noncaptive-linear-stepper-motor-34mm-body-100mm-lead-screw-t5-x-2-p-205.html

    and

    http://www.omc-stepperonline.com/nema-14-bipolar-stepper-75v-05a-23ncm326ozin-14hs170504s-p-94.html

    i thought the same thing...  they already can be sent specific data to rotate a given number of times.  it basically has the hall sensor to count rotations built into its design.  I even thought the best scenario would be to get one of the stepper motors that has a threaded bore (first link), so that the threaded rod connected to the piston would simply be driven directly through the stepper motor body.

    not good at all.

    compared to a standard motor going through a gear set, the stepper motor is a wimp.  when comparing the specs on a stepper motor, the torque they list is "Holding Torque", meaning, when the motor is stalled, it can hold its position very well.  which leads to the next statement.  to get that torque, the motor is constantly using electricity.  the controller is either sending electricity to one set of windings to make the motor move, or sending electricity to a different set of windings to make the motor hold its position (basically an electromagnet).  this drains the battery much faster than a brushed or brushless motor that is only using electricity when it is moving.

    i even tried using the stepper motor with the same gearbox that i built for the brushless motor.  still no good.  under the smallest load, the motor simply stalls rather than rotating, so even with the gearbox, it would stall 2-3% of the time.  meaning to get an accurate count of the rotations of the final gear, you need magnets and a hall sensor on that gear (not inside the motor).  you end up using exactly the same amount of hardware to make the stepper motor a functional system as you do to make a brushed or brushless motor a functional system. no advantage using the stepper motor.

    one final nail in the coffin for the stepper motor:  when run through the gearbox, it was considerably slower than the brushless motor.  using a 12 volt setup to drive the stepper i used, its maximum speed was 600rpm.  not 600kvm, but 600 rpm.  using a 6 volt battery, the brushless motor's speed is 4800 rpm  it took 2 minutes to move my piston from empty to full using the stepper.  the brushless setup moves from empty to full in 15 seconds.

    as to the question John brought up...   you will still want to use limit switches, solely as an emergency backup.  in a perfect world, a brushed or brushless setup with magnets & a hall sensor shouldn't need limit switches either.   but "belt & suspenders"

    finally, the speed of the stepper really isn't constrained by the voltage sent to it, but by how quickly the controller can "fire" a signal to the motor.  in all setups, i used a separate stepper controller to drive the motor, rather than driving from the arduino.

    https://www.sparkfun.com/products/12779

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Fri Nov 13, 2015 6:05 pm

    all in all i was really disappointed in how poorly the stepper worked. but if you look at how the steppers are used in things like the 3d printers, they use bearings and stainless rods everywhere, making for a mass that gets moved with very little friction. i guess a tight fitting o-ring creates a little more friction than a ball bearing.

    tsenecal
    Guest

    Posts : 88
    Join date : 2015-04-01

    Re: PIC and Arduino microprocessors

    Post  tsenecal on Fri Nov 13, 2015 6:09 pm

    if i can find some photos i took of the stepper version of the test ballast tank vs the brushless version, i will upload them.
    avatar
    profesorul
    Guest

    Posts : 384
    Join date : 2011-07-03
    Age : 53
    Location : Bucuresti, ROMANIA

    Re: PIC and Arduino microprocessors

    Post  profesorul on Fri Nov 13, 2015 6:40 pm

    @ tsenecal

    THANK YOU for the useful informations .
    Bring some "light" upon the the subject .

    MARIUS
    avatar
    John Wrennall
    AMS member

    Posts : 157
    Join date : 2011-11-16
    Age : 71
    Location : Leyland

    Re: PIC and Arduino microprocessors

    Post  John Wrennall on Fri Nov 13, 2015 6:56 pm

    Cheers for your information on stepper motors Tim

    Its always good to get feedback like this before needlessly delving deeper into a subject.
    The friction from the O-ring had already given me a few doubts.

    I have already ordered some cheap (£5.00) unipolar motors and controllers for experimentation purposes, looks like they may end up as Christmas decorations.....

    Sponsored content

    Re: PIC and Arduino microprocessors

    Post  Sponsored content


      Current date/time is Sat Dec 16, 2017 10:38 pm