Got a new project for work
jsaddiction
Posts: 84
Ok i have been tasked with designing a simulator/tester for a gyrocompass converter. This gear will accept a wide gamut of input signals from an old analogue gyro and convert it to NEMA0183 data for use in various navigational equipment. What i started doing was working with the step-by-step portion of the inputs. The system under test will accept a signal between 20v to 100vdc. This happens on three wires with one extra wire for GND (S1, S2, S3, REF) I figure an optoisolator and a common emmiter set up would be sufficient to take the 3.3vdc from the prop to the required input voltage. Current draw on the inputs is unknown at this point but i wouldn't imagine it would be much. The signals are as follows:
step # S1 S2 S3
1 H L L
2 H H L
3 L H L
4 L H H
5 L L H
6 H L H
This is all set up in a DAT table using byte sized binary and using a repeat loop it seams to light up the lights on my Prop BOE pretty well and in order.
Here is the issue: The unit under test requires a 36X step by step meaning all 6 steps will be cycled through before you increase by one degree. 216 steps in total. I am trying to display a mathematicaly calculated "current Heading" and compare it with the unit under test's heading. I need this to be accurate to the 1ths of a degree. The math doesn't seem so simple as each step = .00629 degrees??? how can i do this?
step # S1 S2 S3
1 H L L
2 H H L
3 L H L
4 L H H
5 L L H
6 H L H
This is all set up in a DAT table using byte sized binary and using a repeat loop it seams to light up the lights on my Prop BOE pretty well and in order.
DAT states byte %100, %110, %010, %011, %001, %101
Here is the issue: The unit under test requires a 36X step by step meaning all 6 steps will be cycled through before you increase by one degree. 216 steps in total. I am trying to display a mathematicaly calculated "current Heading" and compare it with the unit under test's heading. I need this to be accurate to the 1ths of a degree. The math doesn't seem so simple as each step = .00629 degrees??? how can i do this?
Comments
This with give you tenths of degrees. Note that the maximum number of steps is going to be 3,414,123 ( 2^31 / 629).
i would like to replace the decCurHead ++ with some sort of function that will increas the decimal variable. I am just not sure that after 80 degrees of slewing the heading will be correct.
I am not sure I understand your explanation. I am guessing that the 6 states are the drive signals for a motor. It sounds like you are saying that you have to step through the states %100, %110, %010, %011, %001, %101 thirty six times (a total of 216 steps) to turn the gyro 1 degree. Is this correct?
If this is correct where does the 0.00629 degrees per step come from. If there are 216 steps per degree I get 0.004629629 degrees per step. Is this just a typo?
Of course if the gyro turns in both directions this would have to be accounted for in the counting and calculations.
After looking at your code more carefully it appears you are already doing what I suggested but you may not be taking the correct number of steps in the loops. Hard to be sure without seeing all the code.
you are correct sir. that was a typo thank you for pointing that out. also after working out some numbers i found that i could just increment my decimal value by 0.125 every 27 steps and then trunicate the value to show only the tenths place. I am going to work with that some and see what i come up with. I haven't posted the whole code yet because it is in a state of embarrasing disarray. I will try to clean it up and add the solution i am talking about. i am also going to write it so that it will use the serial terminal object for user input and to watch the numbers shift. That way people can upload it and "see" what im talking about. This problem is kinda hard to explain. You are correct and incorrect about it driving a motor. The gyrocompas converter is just a peice of equipment that converts those stepped signals to a nema HDT string. As the code moves along i will include something to watch the nema sentences and once the prop has completed the slewing process it will look at the nema sentences from the converter and return an error. Thank you for your help everyone. Please let me know if there is any more insite into this project. I have to get this up and running as soon as I can as this peice of equipment has lost any commercial repair and now i am the sole sorce for repair and the broken parts are mounting up.
As an example, let's say the current heading is 21300 steps. This is (21300*3600 + 77760/2)/77760 = 986 tenths of a degree, or 98.6 degrees. Now let's say you want to move to 101.3 degrees. This heading is (1013 * 77760 + 1800)/3600 = 21881 steps. So you would need to move (21881 - 21300) = 581 steps.
first way variable might hold 36. The screen should display "36"
second way variable might hold 13. The screen should display "013" the end result is to have a heading value of something like 3264 in a variable and display "326.4" on the display and if the variable had 902 display "090.2" on the lcd.
I know it was long and i apologize. I haven't updated this thread in a while and a lot of time has gone into this project. If interested I could post some code. I am acctually considering posting the quadrature object on the OBEX after some scrutinizing of course
The data needs to be shifted 1 + the number of leading zeros to the right, and the decimal point and leading zeros inserted. The amount to shift can be calculated by subtracting the index (actual number of digits) from 5 (number of digits you want + decimal point). The number of leading zeros to insert is 1 less than the shift amount.
The relevant code looks like this:
If you're LCD object contains a version of FullDuplexSerial, you may already have these methods. If not, you should be able to add them. I think you can also do this using the Numbers object:
I think this method is a bit more complicated but I think it has more options (space, commas, etc). Have a look at the Numbers object. It has a large table that details all the different formats.
Congrats on your success.
Peter
Stepper CTRL.spin
So the project is going well. The user interface is almost done just polishing it off and trying to correct some bugs. It seems that the first object i wrote is not working as it should. guess i didn't test it enough before using it to develop my UI. For the life of me i can not figure out why it behaves the way it does. Firstly i have the Prop BOE and i have B1-P0 / G1-P1 / R1-P2 connections made to visualize what is happening. I built this quick demo object to run the "stepper CTRL" object. first you call the start method and pass it the step type (1,36,180). Secondly with everything initilized at 0 including your heading you can then call the goto method and it will do some calculations (not fully ironed out) and store that into the ordrHead variable. the cog will read this variable and slew then calculate which direction to slew and how fast to do it. everything works fine if you use a moving right type of heading shift as the first thing to do. if you move left first then it seams P2 stays high and the heading variable changes which means its getting through the step changing instructions but it never seams to output the correct patterns on the leds. Kinda weird youll have to see for yourself. I uploaded the source code of both programs for your reading pleasure. Be kind like i said its my first program.
something like that but maybe more customized for each "state" to load or build a loop that each state change would go through. the output wave form while "stepping" through the heading should look like three squarewaves 120degrees phase shifted so that only two of the output pins are high at once. This generates a 6 bit grey code of sorts that the gyrocompass converter uses to generate NMEA0183 sentences for VHW and HDT
The above listed code.. is it nessisary or should i just use the MOV command assuming i have other pins doing other things elsewhere in the program? ie when using the MOV command and using a literal in the source field of 3 bits in length, will it only effect just those 3 bits or whill the MOV command set the unspecified bits to lows and effect the entire 32 bits of the OUTA?
I got all the circuitry all hooked up and started playing around with it and noticed one out standing problem. When i use a slew rate of 10 degrees or less the converter follows exactly. When i get closer to the converters upper limit of 30 degrees per second it seams to have an error inbetween 1 to 5 degrees. I think that this is because when i hit the "go" button it immediatly is outputing the pulses at full slew rate. Of course this is different than how a boat acts. I think i need to add the function of a ramp speed into my pasm code. Does anyone have any pointers on how to implement this into my code?
exactly! well done.
As long as the cog has just the used pins as output you are fine.
After looking at your pasm I think the most easy way would be to change the slew rate to create ramping. Just start and end the first and last (or 2 each) steps with double slew-rate. (2 x waitcnt)
So go 'half speed' before 'full speed'. This might already do it, its more like '2 steps' and not a ramp.