Shop OBEX P1 Docs P2 Docs Learn Events
Starting a Cog — Parallax Forums

Starting a Cog

DiscoveryDiscovery Posts: 606
edited 2014-06-11 19:04 in Propeller 1
Hi Andy,
I used your reference material to attempt to start a cog in my Plasma Cutter controller code. I was successful in migrating the PBasic code for the BS2 into C code for the Propeller. The code is quite complex but the code can move the X and Y stepper motors to describe a cut from any point to any other point to an accuracy of 0.0011 inches anywhere on an area of two feet by seven feet.

This code runs perfectly but the compiler generates lots of warnings. I don't know how to get rid of the warnings.

The next step is to add code that starts a new cog that controls the height of the plasma cutter head above the work piece independent of the x and y movements. The plasma cutter provides a smooth changing voltage from 0 to 8 volts DC that covers the cutting head range between the cutter head and the work piece. I want to input this voltage through an ADC (the one on my Propeller Activity Board), compare the digital representation to a reference word (the correct position for the head), generate UP and Down counts to an AD5220 digital potentiometer that outputs a DC voltage from -12 to +12 volts. This output drives a DC gear motor to position the Plasma Head using a rack and pinion assembly. I use this method on a BASIC Stamp BS2 for servo positioning movable items. It works perfectly well.

I followed your procedure step by step.

I included a forward declaration for the cog just after the #include libraries...void Zaxis();
#include"simpletools.h"
void Zaxis();
This compiled fine.

I included the cog at the end of the C code. All the servo code will be placed here...reading the ADC, making comparison, and generating UP/DOWN counts for the AD5220 digital potentiometer. This will check if the cog is working.
void Zaxis();
{
HIGH(1);
}

This code compiled fine.

I included the cog_run instruction as the first instruction in the main().
main()
{
cog_run(Zaxis,50);
...;
...;
}

This line will not compile. If I make it a comment line...it will compile.

A list of build faults follows.
4.6.1 Propellergcc_v1_0_2162
71:1 warning...
73:1 warning implicit declaration of 'cog_run' [Wimplicit function declaration]
82: 5 warning implicit declaration of function 'StepperMotorM1'
83:5 warning
93:6 warning
104:5 warning
122:7 warning
200:3 warning
260:1 warning
324:1 warning
327:1 warning
374:1 warning
387:1 warning
387:1 warning
401:1 warning
401:1 warning
438:1 warning
438:1 warning
474:1 warning
0x4c2 undefined reference to '_cog_run'

What is wrong?

Discovery

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-06-11 08:40
  • DiscoveryDiscovery Posts: 606
    edited 2014-06-11 10:52
    No.

    I have not down loaded the folder in several months. The reason is that the development systems computer stays off the internet unless it needs maintenance.

    I will execute a down load now.

    The file was down loaded, unzipped, and files extracted. Now to see if it did any good.

    Discovery
  • DiscoveryDiscovery Posts: 606
    edited 2014-06-11 11:09
    The down load did not have any effect on the compilation. There are lots of warnings about illicit function declarations. It lists all my functions as illicit...but they run fine on the Propeller.

    The cog_run(Zaxis,50) will not compile.

    The files were extracted...is there anything else that I should do to make them available for the SimpleIDE compiler?

    Discovery
  • jazzedjazzed Posts: 11,803
    edited 2014-06-11 11:46
    Make sure the following is checked:

    Menu Tools -> Properties -> General Tab -> Auto Include Simple Libraries

    Make sure the Simple Libraries folders are set correctly in:

    Menu Tools -> Properties -> GCC Folders -> Library Folder
    Menu Tools -> Properties -> GCC Folders -> Workspace Folder

    Click the Browse buttons to set if necessary.
  • DiscoveryDiscovery Posts: 606
    edited 2014-06-11 14:55
    Jazzed,
    The menu Tools are set as you stated above. Still no compile.

    Tomorrow I will be unavailable for about two weeks.

    Discovery
  • jazzedjazzed Posts: 11,803
    edited 2014-06-11 15:38
    Discovery wrote: »
    Jazzed,
    The menu Tools are set as you stated above. Still no compile.

    Tomorrow I will be unavailable for about two weeks.

    Discovery

    Please right-click the build output, select all, copy all, and paste here. It would be good to see your main .c file as well. Do you have any other files associated with your project? What does the SimpleIDE title say at the top?
  • jazzedjazzed Posts: 11,803
    edited 2014-06-11 16:18
    I just noticed this.

    You have an extra semicolon ';' after void Zaxis(). Please remove it.

    void Zaxis();
    {
    HIGH(1);
    }
  • DiscoveryDiscovery Posts: 606
    edited 2014-06-11 16:57
    Shall do.

    Discovery
  • DiscoveryDiscovery Posts: 606
    edited 2014-06-11 19:04
    The extra semicolon you picked up was a transcription error on my part. There was no extra semicolon; however, I checked cog_run(Zaxis,50) and found there was an extra semicolon there.

    I removed it and the cog_run instruction compiled; however, the compiler highlighted numerous lines of code as errors which were not errors before such as x=1; so I will get back at this in about two weeks. Thanks for catching the error.

    Discovery
Sign In or Register to comment.