Arduino/Mendel 90

Advert

Arduino/Mendel 90

Home Forums 3D Printers and 3D Printing Arduino/Mendel 90

Viewing 25 posts - 1 through 25 (of 28 total)
  • Author
    Posts
  • #31630
    Rod Ashton
    Participant
      @rodashton53132

      Sketch compiling

      Advert
      #463645
      Rod Ashton
      Participant
        @rodashton53132

        I am revisiting my old Mendel 90 printer and have recalibrated and leveled the bed. Then reset the "Z" height to suit in the Arduino sketch. The sketch will not compile and issues the following report :-

        core.a(main.cpp.o): In function `main':

        C:UsersRodREPRAP1Original MD90 files3D Printingarduino-1.0.1-windowsarduino-1.0.1hardwareMelzicoresarduino/main.cpp:11: undefined reference to `setup'

        C:UsersRodREPRAP1Original MD90 files3D Printingarduino-1.0.1-windowsarduino-1.0.1hardwareMelzicoresarduino/main.cpp:14: undefined reference to `loop'

        Could anyone kindly offer some advise as to what is wrong here?

        #463647
        John Haine
        Participant
          @johnhaine32865

          What are you compiling it with? 'setup' and 'loop' are Arduino functions not I think defined in C so wouldn't be recognised by a normal C compiler. You would need to use the Arduino IDE, but that's free to download.

          #463665
          Rod Ashton
          Participant
            @rodashton53132

            John – Thanks for reply. I am using Arduino IDE. Very puzzled, sadly have forgotten my arduino knowledge since two years past.

            #463666
            SillyOldDuffer
            Moderator
              @sillyoldduffer

              Another possibility is the Arduino project (with several source files) has parts missing.

              But I agree with John, the Arduino environment expects to link into user provided setup() and loop() functions. The file called main.cpp suggests a source / Arduino IDE mismatch.

              main() is standard 'C', in which the programmer writes the equivalent of setup() and loop() himself. Because the "set-up then loop forever" pattern is so common on microcontrollers, Arduino automate it for beginners.  It's an Arduino only feature.

              main.cpp probably wasn't written specifically for the Arduino IDE. Where did it come from? If I can see the code, or better the write-up, might be easy to convert it, or suss out what the Arduino environment needs to be told.

              For info:

              setup() is automatically run once when the computer starts; it's used to initialise things like the Serial interface or whatever. It can be empty.

              loop() is run repeatedly thereafter, forever. Usually most of 'keep doing this' logic is in loop(), and it either does all the work itself or controls the functions that do. It can be empty too, but that's unusual.

              A new Arduino program is created automatically by the IDE like this:

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

              }

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

              }

              Standard C would do the same thing with something like:

              void main() {

              // Setup code here to run once

              while( true ) {

              // loop forever, main code here, to run repeatedly:

              }

              As can be seen, the two forms are almost trivially similar, but the Arduino IDE insists on the first method.

              Dave

              Edit typos galore!

               

               

               

              Edited By SillyOldDuffer on 10/04/2020 10:49:51

              #463678
              Rod Ashton
              Participant
                @rodashton53132

                SoD – Sorry lost me a bit there. The original file was given with the Mendel 90 and was a "nophead" download.

                As one old duffer to another, could you explain "setup code" and "main code" please?

                #463681
                Nick Clarke 3
                Participant
                  @nickclarke3

                  Does the printer require any non standard libraries to compile? – and are these functions in such a library?

                  If the library is not included in the ide it won't be linked in.

                  This has happened to me at least twice –

                  • When updating to a newer version of the ide – without the required library
                  • When putting my code on a USB and trying to compile on a different machine – again, without installing the library first

                  Mind you, you should perhaps see my personal list of daft things I've forgotten when programming – I'd send you a copy but it is too heavy to post ……….

                  Edited By Nick Clarke 3 on 10/04/2020 11:53:17

                  #463725
                  SillyOldDuffer
                  Moderator
                    @sillyoldduffer
                    Posted by Rod Ashton on 10/04/2020 11:34:05:

                    SoD – Sorry lost me a bit there. The original file was given with the Mendel 90 and was a "nophead" download.

                    As one old duffer to another, could you explain "setup code" and "main code" please?

                    A simple example may be clearer.

                    First, an Arduino Uno.

                    dsc06222.jpg

                    A small microcomputer is mounted on a board the size of a credit-card. The board provides USB access to a PC (where new programs are developed), a power-supply, crystal oscillator clock, and sockets and pins so the user can connect other electronic devices, either reading or writing to them. It also contains a bootloader, allowing existing programs to be replaced with new ones.

                    A new Arduino does nothing. It has to be programmed to do something useful, such recognising that an input pin (or pins) have changed, and using that information to change the outputs. Input and output relationships can be arbitrarily complex, and involve timers to control a sequence, where the sequence can be altered by the object being controlled. For example, firing a rocket only when the tanks are full and the hoses disconnected:

                    | WHILE PREPARING_TO_LAUNCH:
                    |    OPEN FUEL_INPUT_VALVE
                    |    OPEN OXYGEN_INPUT_VALVE
                    |       IF FUEL_TANK == FULL and OXYGEN_TANK == FULL
                    |            CLOSE FUEL_VALVE
                    |            CLOSE OXYGEN_VALVE
                    |                 DISCONNECT
                    |                 IF DISCONNECT_FAILED
                    |                    ABORT
                    |                 ELSE
                    |                    OPEN OXYGEN_OUTPUT_TO_ENGINE
                    |                    WAIT 15 SECONDS
                    |                    START SPARK_IGNITER
                    |                    OPEN FUEL_OUTPUT_TO_ENGINE

                    When an Arduino is powered up, the bootloader checks to see if a new program is available. If not, it does a bunch of house-keeping needed to set the ball rolling (like activating a Serial USB interface a PC understands), and then starts the user program.

                    The first part of the user program is in setup(), and it does whatever the user needs to make his program work like allocating pins as inputs or outputs.

                    When the Arduino IDE opens a new Sketch (Arduino speak for 'program' ), the user gets this screen:

                    emptysketch.jpg

                    This is a valid program that can be compiled and downloaded onto an Arduino board. As setup() and loop() are empty, it does absolutely nothing. setup() does nothing once. loop() does nothing, very quickly, over and over again, until the power is turned off.

                    A simple example that does something useful. It blinks the tiny LED marked 'L' top right on the board. It also turns PIn 13 on and off on the adjacent socket. Socket 13 could drive a relay controlling a mains powered lamp, or a klaxon, or whatever.

                    blink.jpg

                     

                    In the example, pinMode() declares how pin 13 will be used. Setting pin 13 up as an output only needs to be done once, so it's sensible to put the code in setup().

                    Making the LED blink repeatedly sounds like a job for loop(), and it is. After running setup(), the Arduino calls loop(). Inside loop it finds an instruction telling it make pin 13 HIGH, which is +5V on the Arduino Uno. The next instruction tells the Arduino to wait for 1000 milliseconds before executing the next instruction. Then pin 13 is made LOW, which is 0V. The next instruction is another 1 second delay and loop() finishes.

                    When loop() exits, the Arduino immediately calls loop() again, and the sequence is repeated. So the LED flashes ON for 1 second, then OFF for 1 second, repeat forever.

                    A reprap printer follows the same basic sequence, but the code will be much more complicated. Rather than switching a single LED on and off, the Arduino will receive and decode print commands causing it to send streams of pulses to the X,Y and Z motors, setting them forward or reverse, and feeding plastic. Probably also checks temperatures and end-stops to stop printing if anything goes wrong.

                    I'll search for Mendel 90 and "nophead" to see if I can cast any light on your particular problem.

                    Dave

                    Edited By SillyOldDuffer on 10/04/2020 14:44:18

                    #463735
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer

                      Bit of digging.

                      The Mendel 90 is an early Reprap printer, in a number of physical variations.

                      First driver for the printer found is a RaspberryPi / Python combination – not what Rod has.

                      Second is based on a Sanguino, which looks to be a microcontroller outside the Arduino family. Like the Arduino it uses Atmel chips, but big brother – more memory and pins. Seems to have been popular for Reprap and there's a board called the Sanguinololu – this appears to be a Sanguino plus the motor controllers etc needed for 3D printing.

                      The Sanguino can be programmed from the Arduino IDE but it's a third party extension, not one of the standard boards. Instructions on how to add it to the Arduino IDE at Sanguino.

                      Not sure how compatible it still is. The software is 6 years old for Arduino 1.0 and the current Arduino version is 1.8.12 Earlier versions of the Arduino IDE are all still available here, but I don't know how compatible they are with Rod's computer.

                      I suggest installing Sanguino on the IDE and recompiling again with Sanguino as the target. Being a third party board, it may not insist on setup() and loop()

                      May be an example of something simple at the time, but hard now! The question might be better answered by a reprap forum – the boards are still being sold.

                      Dave

                      #463758
                      Rod Ashton
                      Participant
                        @rodashton53132

                        SoD – Thanks for your help with this.

                        I have downloaded Ard. 1.8.2 . Tried the programme and it compiled to some degree but the Arduino did not recognise my Melzi board or have it included in the board list. Though it did correctly see that something was connected to COM3.

                        Guess 1.8.12 is too up to date. I presumed incorrectly that it might identify the card back thro the USB. only conclusion I can draw is that I did have a corrupted version of my original IDE.

                        Been at it for seven hours pretty solid so will try to download earlier clean copy tomorrow. If I have not thrown it "int cut"

                        #463769
                        Nick Clarke 3
                        Participant
                          @nickclarke3

                          Have you tried to contact nophead via GitHub?

                          #463780
                          Rod Ashton
                          Participant
                            @rodashton53132

                            Nick – Not directly but I have posted on the Mendel 90 page.

                            #463792
                            SillyOldDuffer
                            Moderator
                              @sillyoldduffer
                              Posted by Rod Ashton on 10/04/2020 16:44:30:

                              I have downloaded Ard. 1.8.2 . Tried the programme and it compiled to some degree but the Arduino did not recognise my Melzi board or have it included in the board list. Though it did correctly see that something was connected to COM3.

                              Guess 1.8.12 is too up to date. I presumed incorrectly that it might identify the card back thro the USB. only conclusion I can draw is that I did have a corrupted version of my original IDE.

                              I found wise words on the Melzi here. Seems it's an improved Sanguinololu, and should be compatible with it.

                              I guess you're trying to reload Marlin. The Melzi site says:

                              "There is a version of the Marlin RepRap firmware for Melzi on RepRapPro Ltd's Github repository here. It contains the extra files needed for the Arduino IDE to talk to a Sanguino (and hence to the Melzi). "

                              Slightly worrying is talk of using avrdude or an Arduino Uno configured as a bootloader. It suggests the Melzi doesn't have a built-in bootloader, meaning there's an extra step to do. The Arduino IDE does the initial compile but not the download. Instead the compile saves a binary object file, probably suffixed .HEX, which is installed by a separate bootloader like avrdude.

                              See the section on 'Bootloader Upload' on the Melzi page, while a little intimidating, it looks complete.

                              What errors are you getting? Although I'm reading the Melzi blurb as 'complicated', it might be easy when you know how. Trouble with web research is old solutions to computer problems get found, whilst the later easy fix disappears into the fog.

                              Dave

                              #463838
                              Andy Stopford
                              Participant
                                @andystopford50521

                                I seem to remember having a difficulties with this after replacing a burnt-out mainboard on my Wanhao i3.

                                If you go to Tools>Board: and hover the mouse pointer over this entry, a fly-out menu should appear. Scroll down it to see if Sanguino W/ATmega1284 is listed. if not proceed as follows:

                                Close the IDE

                                You have to make sure that the your boards.txt file has an entry for the sanguino board. This file is inside the arduino IDE folder. Here is the path to mine:

                                /home/andy/Programs/Arduino/arduino-1.8.9/hardware/arduino/avr/

                                I would guess that on a Windows machine the path would be Program Files/Arduino etc.

                                Open boards.txt in a text editor and copy/paste the following to the bottom of the file and save.

                                ##############################################################

                                atmega1284p.name=Sanguino W/ ATmega1284 or ATmega1284P (16MHz)

                                atmega1284p.upload.maximum_size=130048
                                atmega1284p.upload.maximum_data_size=16384

                                atmega1284p.upload.protocol=arduino
                                atmega1284p.upload.speed=115200
                                atmega1284p.bootloader.path=optiboot
                                atmega1284p.bootloader.file=optiboot_atmega1284p.hex

                                atmega1284p.bootloader.low_fuses=0xFF
                                atmega1284p.bootloader.high_fuses=0xDE
                                atmega1284p.bootloader.extended_fuses=0xFD
                                atmega1284p.bootloader.unlock_bits=0x3F
                                atmega1284p.bootloader.lock_bits=0x0F

                                atmega1284p.build.mcu=atmega1284p
                                atmega1284p.build.f_cpu=16000000L
                                atmega1284p.build.board=AVR_SANGUINO
                                atmega1284p.build.core=arduino:arduino
                                atmega1284p.build.variant=sanguino

                                ############################################################

                                atmega1284p_8m.name=Sanguino W/ ATmega1284 or ATmega1284P (8MHz)

                                atmega1284p_8m.upload.maximum_size=130048
                                atmega1284p_8m.upload.maximum_data_size=16384

                                atmega1284p_8m.upload.protocol=arduino
                                atmega1284p_8m.upload.speed=57600
                                atmega1284p_8m.bootloader.path=optiboot
                                atmega1284p_8m.bootloader.file=optiboot_atmega1284p_8m.hex

                                atmega1284p_8m.bootloader.low_fuses=0xFF
                                atmega1284p_8m.bootloader.high_fuses=0xDE
                                atmega1284p_8m.bootloader.extended_fuses=0xFD
                                atmega1284p_8m.bootloader.unlock_bits=0x3F
                                atmega1284p_8m.bootloader.lock_bits=0x0F

                                atmega1284p_8m.build.mcu=atmega1284p
                                atmega1284p_8m.build.f_cpu=8000000L
                                atmega1284p_8m.build.board=AVR_SANGUINO
                                atmega1284p_8m.build.core=arduino:arduino
                                atmega1284p_8m.build.variant=sanguino

                                ############################################################

                                Re-open the IDE and see if you now have a menu entry for Sanguino. If so, make sure you have that selected before trying to upload the sketch (I think it's the 16MHz entry, but not certain).

                                #463919
                                Rod Ashton
                                Participant
                                  @rodashton53132

                                  SoD & Andy – Thanks guys for assistance. Stirred the brain cells and recalling bits. Wish I could find my notes from the installation.

                                  Andy – I think you may have found what I need. I had a Melzi directory on the old IDE which contained the ATmega1284P. Will put the code in later today and report.

                                  #463932
                                  Rod Ashton
                                  Participant
                                    @rodashton53132

                                    Andy – Sorry to be a pain. I have added the script to the boards.txt file in Arduino/arduino-1.8.9/hardware/arduino/avr/. But when trying to save, I get the report :- "You do not have permission to open this file. See the owner of the file or an administrator to obtain permission"

                                    #464067
                                    Andy Stopford
                                    Participant
                                      @andystopford50521

                                      Windows doesn't like you to muck around with the contents of the Program Files folder (I'm presuming that's where Arduino is) – you need to have "Elevated Permissions" to do this.

                                      Its a long time since I've used Windows, and I think what you have to do depends on which version you have, but here are a some links to possible solutions:

                                      https://social.technet.microsoft.com/Forums/ie/en-US/3dd0d2f9-5b2f-46df-950f-36887c98369c/give-full-permission-for-the-users-in-program-files-folder?forum=w7itprogeneral

                                      https://www.howtogeek.com/howto/windows-vista/enable-the-hidden-administrator-account-on-windows-vista/

                                      Log on as Administrator in Windows 10

                                      The latter two links allow you to login as "Administrator", after which you may be able to edit the boards.txt file OK

                                      #464123
                                      Rod Ashton
                                      Participant
                                        @rodashton53132

                                        Andy – Appreciate your help. Thanks

                                        #478168
                                        Rod Ashton
                                        Participant
                                          @rodashton53132

                                          Gentlemen – Returning to this problem after an enforced sidetrack. – Have reloaded my old backup "sketch" .

                                          This will not compile again. Giving the report " :Invalid line format, should be`key=value` "

                                          Any assistance gratefully recieved.

                                          #478183
                                          SillyOldDuffer
                                          Moderator
                                            @sillyoldduffer
                                            Posted by Rod Ashton on 07/06/2020 12:24:50:

                                            This will not compile again. Giving the report " :Invalid line format, should be`key=value` "

                                            Any assistance gratefully recieved.

                                            Can you post the full error output shown in the black lower pane? As this is normally only a few lines long, and has to be scrolled, the detail's probably hidden under the source code edit pane.

                                            The lower pane can be expanded by moving the mouse on to the thin grey line where it changes to an up and down arrow that can click-hold and move the line. (The screenshot shows the 'move' cursor in the wrong place.)

                                            arduinopane.jpg

                                            Anyway, pulling the grey line up makes more of the error messages visible, if any:

                                            arduinobigpane.jpg

                                            What's in the black pane after a failed compile?

                                            Dave

                                            #478188
                                            Rod Ashton
                                            Participant
                                              @rodashton53132

                                              Dave – After moving the panel. I tried to compile again and the message has now changed to "Error compiling for board Sanguino W/ ATmega 1284 or ATmega 1284p (16 MHz)

                                              #478197
                                              SillyOldDuffer
                                              Moderator
                                                @sillyoldduffer
                                                Posted by Rod Ashton on 07/06/2020 13:15:27:

                                                Dave – After moving the panel. I tried to compile again and the message has now changed to "Error compiling for board Sanguino W/ ATmega 1284 or ATmega 1284p (16 MHz)

                                                 

                                                Is that all it says?

                                                Try going to FIle->Preferences and in the settings tab tick the compilation and upload boxes in 'Show verbose output during:'

                                                Can you see what that says first?

                                                However, I suspect an incompatibility between the latest IDE and the original Sanguino set-up.

                                                Re-reading this thread, Andy Stopford explained how to manually set the Arduino IDE boards.txt file for Sanguino, which is an add-on and not part of the Arduino core. As I see you had permissions problems, the data might be out of date or flawed.

                                                Helpfully, I notice the Settings tab now has an 'Additional Boards Manager URLs:' entry to make add-ons like Sanguino easier to manage. Clicking on the icon at the end of the line opens an 'Additional Boards Dialogue', with a 'Click for list of unofficial boards support URLs' hyperlink. That opens a page where Sanguino is under Kristian Sloth Lauszus

                                                We might try deleting the existing Sanguino set-up with the Board Manager, adding the Kristian Sloth Lauszus .json URL to the list of Additional Boards, and then re-loading Sanguino with the board manager. With luck the IDE will do all the work, including permissions, and install an up-to-date Sanguino configuration compatible with the latest Arduinio IDE.

                                                But see if you can get more error info first – could be something simple.

                                                At a disadvantage here – I know nothing about Sanguino! Perhaps Andy is about?

                                                Dave

                                                 

                                                Edited By SillyOldDuffer on 07/06/2020 13:58:42

                                                #478200
                                                Rod Ashton
                                                Participant
                                                  @rodashton53132

                                                  Dave – Contacted Nophead who is the originator of the machine software. He says the same. That the Arduino IDE is too new. Just downloading an old version which may be better.

                                                  #478201
                                                  SillyOldDuffer
                                                  Moderator
                                                    @sillyoldduffer

                                                    Gosh, nothing is ever easy! Fingers crossed.

                                                    Dave

                                                    #478210
                                                    Rod Ashton
                                                    Participant
                                                      @rodashton53132

                                                      So with the old IDE it still will not compile. But reports :- " ~main. CPP40 undefined reference to `setup` " and " main. CPP40 undefined reference to `loop`"

                                                      ?

                                                    Viewing 25 posts - 1 through 25 (of 28 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up