Click here to Skip to main content
15,887,449 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Experts,
I'm trying to produce a set of quadrature output which is shifted at 90deg by manipulating a pair of 0-5 volt signals from an SDS device as below:

// Channel A ON
canL2->SDSWriteAO(0x27C, 1, 0x13, 5); // 5 = 5V output			
// Channel A OFF
canL2->SDSWriteAO(0x27C, 1, 0x13, 0); // 0 = 0V output

// Channel B ON
canL2->SDSWriteAO(0x27C, 2, 0x13, 5);					
// Channel B OFF
canL2->SDSWriteAO(0x27C, 2, 0x13, 0);


I need to achieve maximum speed 200 ft/m with above resources.
Any feedback is highly appreciated.

Thanks in advance,
mraaf

What I have tried:

// Speed control by manipulating OnTimer() timout
int nTimout = static_cast<unsigned int>(1000/m_nSliderCtrl); // 0-200 ft/m
SetTimer(1, nTimout, NULL); // Timer 1


DWORD dwInterval = static_cast<unsigned long>(nTimout/3);

// calling OnTimer() for Timer 1 
if(nIDEvent == 1)
{
// Encoder rotation Clockwise
// at 0deg			
canL2->SDSWriteAO(0x27C, 1, 0x13, 5); // Channel A ON				
canL2->SDSWriteAO(0x27C, 2, 0x13, 0); // Channel B OFF
Sleep(dwInterval); // shift duration

// at 90deg
canL2->SDSWriteAO(0x27C, 1, 0x13, 5); // Channel A ON				
canL2->SDSWriteAO(0x27C, 2, 0x13, 5); // Channel B ON
Sleep(dwInterval);

// at 180deg
canL2->SDSWriteAO(0x27C, 1, 0x13, 0); // Channel A OFF				
canL2->SDSWriteAO(0x27C, 2, 0x13, 5); // Channel B ON
Sleep(dwInterval);

// at 270deg
canL2->SDSWriteAO(0x27C, 1, 0x13, 0); // Channel A OFF				
canL2->SDSWriteAO(0x27C, 2, 0x13, 0); // Channel B OFF
Sleep(dwInterval);
}


Output:
Output volt = 1.25V
Stable output 0-25Hz = 0-10 ft/m
Unstable output 25-50Hz = 10-20 ft/m
Max out at 50Hz (20ms)

What I have discovered:
12.5Hz = 5 ft/m --> Stable
25.0Hz = 10 ft/m --> Stable
50.0Hz = 20 ft/m --> Unstable, channel B occasionally shifted ahead channel A (resulting anti-clockwise rotation)
100.0Hz = 40 ft/m --> Unachievable
Posted
Comments
Patrice T 14-Mar-18 0:04am    
Are you sure it is about programming?
mraaf 14-Mar-18 0:06am    
Yes, I'm pretty sure I need to fix my coding
Patrice T 14-Mar-18 0:07am    
And you have showed your coding ?
mraaf 14-Mar-18 0:23am    
Well that's what I tried, I'm sure the sequence of producing the a cycle of quadrature is correct (A ON, B OFF -->shift 90deg--> A ON, B ON -->shift 90deg--> A OFF, B ON -->shift 90deg--> A OFF, B OFF), but there are variables such as shift timing (Sleep() in this case), cycle timer (OnTimer()) might need to fix or incorrectly manipulated.
mraaf 20-Mar-18 0:47am    
Hello,
Any idea or tips?

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900