Using Objects (Synth.spin, SquareWave.spin CLOSED: END OF DISCUSSION
bbrien
Posts: 561
I am trying to use the above objects to generate a 8 and 10 Hz signal on two counters of a single cog. My counters are declared in the con section of my program. the Pin numbers are declared separately. but I don't know where to put the needed frequency. I am including my Program.
Comments
I think we need to move this to P1 thread to get a better response. I can do that if you wish.
If you think it will help.
No objects required -- just some simple PASM running in its own cog.
The waveforms are just like the ones I generated in Experiment1a. I would like to incorporate into the DH15 program . I will remove all of the stepper method since I can't get to work. ( it's in first post of this thread)
You say you want to use the two cog counters to generate frequencies of 8 Hz and 10 Hz, and that the counters are already defined in the CON section. Here is what I see in the CON section and I'm confused about all the numbers there, 50Hz, a couple of 8_0 and a 7.5% and a 9.5 Hz.
In any case, to set up a cog counters for 8 Hz and 10 Hz, you need
Tracy , a lot of information is being disposed of in that program, a new partial program has been completed but untested, and incomplete. maybe you can take a look and help.
Thanks for the reminder, @"Tracy Allen" -- I was tired when I posted last night, and trying to pay a little attention to "The Book of Boba Fett" as a member of the Parallax community works on the show (I occasionally provide bits of P1 code for him). I completely forgot about NCO mode, for which I have a method in my jm_io.spin object.
Edit: Fixed freq_out() method to eliminate loss of bit0
Tested with:
Output attached.
The next morning -- after a cup of coffee -- I coded manually:
The output is just a smidge more accurate than my original freq_out() method which always dropped bit0 of the frqx setting (fixed now).
concerning post #7
I tried to correct an error by adding a pair of phrases to the CON section and got another error ( see Attached File), What does it mean and how to fix.****
Jumpin' Jiminy on a cracker... you can't make method calls from a CON block (only PUB and PRI blocks).
so those phrases have to be used with objects, guess i'll have to use the SquareWave objects. Next error,What is and why do I get da "expected a sub routine name" error ?
The difference between this and my dh14 code is little and it works but the dh15 code doesn't. 15 is on first post and here is 14.
Another question; is this program a spin or a propC.
bbrien,
The changes I see between DH14 and DH15 are:
RA_RATE was changed from 7_5 to 8_0
DEC_SPEED and DEC_DIR were changed to -1 in Motor.Start, which isn't even used.
Step2 was added
Step2.Start was added for DEC
Step2.Set-Speed was added for DEC
Motor was changed to Step2 for DEC for (DEC_RATE * SLEW RATE), (-DEC_RATE * SLEW RATE), (DEC_AUTO), and (-DEC_AUTO).
Motor.Set_Speed(DEC,0) was changed to Motor.Set_Speed(DEC_AUTO)
Programs with a Spin extension (.spin) are Spin programs, and a C program would have a C extension (.c).
All of the programs in this posting are Spin programs.
Spin has some elements of C such as braces, { }.
If you compare dh15 and the originaldh17 the only difference other than pin numbers is the object "stepper". When there was only one instance of "stepper" and one instance of "dualmotorezmod" as in dh14, the stepper object worked fine but, when two objects of "stepper were used the the outputs were "dead", cannot figure out why. I would think the sub routine names could be the same.
bbrien,
Which Stepper.spin are you using because he posted 2 in 'using multiple frequencies to control a stepper motor.'?
You should be using the newer Stepper.spin, which has SCALE = 40, and uses ClkTicks := 20*CLKFREQ in Set_Speed.
bbrien,
You keep adding code, removing it, and then adding it back, as well as changing adds to subtracts and then back to adds again.
I see nothing in Stepper.spin that would be the same in more than one instance but I am not familiar with running Objects more then once.
One thing I would suggest is using RAaxis and DECaxis instead of Step1 and Step2, because maybe you have one of the axes flipped later in the code.
Also, can you explain in words, what should happen when each button is pressed, so I can better understand when values should be negative or positive and added or subtracted.
Now if you comment out one of the Step Objects, does the other one work, and vice versa?
I am using the stepper which scales at 40. I will try commenting out one of the two stepper objects and see what happens. Let you know later
North button drives Dec motor north and South drives Dec motor to south direction. West, RA motor turns west, East turns RA motor in east direction.
bbrien,
I don't know what units your program uses, but according to Telescope.com RA is in Hours (though it can be converted to degrees) and DEC is in Degrees of Arc.
It also says that Declination can only be from +90 degrees to -90 degrees, which would be horizon to horizon; + is to the North and - is to the South.
The drive kit instructions also say that when the RA axis is moving at the Sidereal rate that objects will move Eastward and that when it's paused (Stopped) they will move Westward.
I don't know what kinds of objects you are trying to see, but Telescope.com says that stars are in fixed positions while other objects such as the sun and planets move.
I am just trying to understand how the Telescope system works since I am not familiar with it.
Also, in the Dual Axis thread, you mention Astroview and when I do internet searches it brings up the EQ-3M drive kit.
The EQ-2M and EQ-3M appear to use DC motors while the TrueTrack uses Steppers.
And the Orion handbox has an LED between the 4 compass buttons that is Green when a button is not pressed but turns Red when a button is pressed.
Did you plan on using a Bicolor LED to emulate this function on your handbox?
It is comprised of two motors which have 4 wires in each unit and they act like bipolar steppers when I connect them to a MC3479 stepper driver chip. As for the bicolor Led I'm not using at this time.
DH15 uses the Synth.spin Object which only has 1 Public Method (callable from an outside program) called Synth.
Stepper.spin has the following public methods:
Start
Stop
Set_Speed
Driver
Dave Hein might want to explain what his Driver method does but it appears to toggle the ClkPin back and forth after a time period of ClkTicks.
Start with DH17 and save it as ClkTest, then add a Step2.Driver after the Step2.Set_Speed for a NORTH.
Save it and try running it while pressing the NORTH button and hopefully you will see a clock pulse on a DEC pin.
I'll give it a try and let you know tomorrow have to wait till tomorrow, my wife don't work on this when she home.
I tried it but results are negative.
I am trying an experiment on dh15 changing Step1.set_speed to DEC_Freq.symph and I get a strange error. see what you make of it?
bbrien,
You make it confusing when you keep using the same program name.
At least add a different letter each time so it's easier to tell if the program is new or old.
The Synth Object has 3 Parameters: Counter, Pin, and Frequency.
You have only given 1 Parameter so that is why you are getting an error.
What are you trying to do and are you absolutely positively sure that your wiring is correct?
I am trying to send a 8Hz pulse to pin #17 and a 10Hz pulse To pin# 19. I will Indicate with Arrow, error.
wiring is correct for the initial test. Four sw. on #4,5,6,7 and four leds on #16,17,18,19 which flash or turn on or off . Tested with Frequencysynth.spin . No sw. used with frequencysynth. Also I resend Files as Telescope BS1_A
You can do that in just two lines of code with the method I shared earlier (post #8). You don't need the synth object.
Each cog has two counters -- this uses the ctra for 8Hz, and ctrb for 10Hz.
bbrien,
Telescope BS 1A is the same as the DH15 above it, except that you marked the line that had an error.
Look at page 182 of the Propeller Manual, which is for PUB that declares a Public method or a subroutine that you can use in your programs.
https://www.parallax.com/package/propeller-manual/
Notice the List of Parameters in between the Parenthesis, ().
Your program MUST give the same number of parameters that the method expects, otherwise you will get an error.
Also, some methods will send back a Return Value, as shown above after the Colon, :.
If you are unsure of what Parameters a Method needs or what values it returns then open up it's Mother Object and look at it in another tab.
This is the Synth method from your Synth object.
Notice that this method has 3 Parameters, so you MUST give it 3 values.
The 1st is CTR_AB, and look down the code, you can see that it is looking for an A or a B.
Next is Pin, which is just a pin number, and since the Propeller only has 32 I/O pins, its value must be 0 to 31.
Last is a Frequency, and notice in the 1st line that it only wants from 0 to 128 MHz.
For 8 Hz you would give it 8, and for 10 Hz you would give it 10.
Just beware that some Objects are better written than others.
Synth expects a frequency in Hz while JonnyMac's Freq_Out uses tenths of a Hertz, or 0.1 Hz.
Sometimes Objects have Demo programs that show how to use them.
I haven't been able to get Freq_out to Work yet but I made some changes to Telescope1_A and renamed to Telescope BS 2_B, and it Works to some extent. If you find your "QuickStart ,maybe, you can check it out for me.