I am using Synergy in an industrial controller. We picked Synergy because the controller is part of a complex system and must communicate via Ethernet to a master controller. We also liked the CPU speed and time to market improvements using Synergy.
The application is interesting and works as follows:
- The controller sits in idle most of the time
- A message is received over Ethernet from the master controller to "***" our controller
- We then see a prox signal that pulls the trigger for our control event
- For the next 15 milliseconds we are controlling our mechanical system:
- We get an interrupt from the prox signal and that ISR starts the control and starts a GPT timer to interrupt every 25 microseconds (fast, highest priority)
- Every 25 microseconds we perform the simple digital control and we need to measure and record an analog value
- At the end of the control time (typically 15 milliseconds) we stop the timer and go back to idle. We also set a semaphore to indicate end of process.
- At some time in the future we have a monitor thread operating that sees the process complete semaphore:
- This thread performs analysis of the operation based on the analog value recorded at each 25 microsecond interrupt
- This analysis allows us to auto tune the process and to detect failures and to predict failures
At this time I have the application running and the process cycles performing using the prox IRQ and the timer interrupting each 25 microseconds.
Now I need to get my adc to read a value at each 25 microsecond ISR
- I tried to use the periodic adc framework but I mis-understood its operation. I cannot set it up to start and then record 600 values once per 25 microseconds, then stop
- Using the framework to make one reading triggered by a semaphore is way to slow.
Here is my proposed solution and I am looking for some help to set it up and make it work:
- I propose to set up an adc driver using Synergy configurator
- Set up for one shot operation, no interrupts, no call back function
- Set up my channel, resolution, etc
- Basically use Synergy to set up all the registers in the ADC unit
- I assume I would set this up in HAL_COMMON
- I would use the open function during init of the system
- At this point I would propose to quit using the Synergy driver:
- When I need to do a conversion (at 25 microsecod intervals during the 15 millisecond control period) I would write directly to the ADCSR register, ADST bit to start the conversion
- on the next 25 microsecond IRQ (more than enough time for the conversion to complete) I read the converted value by directly reading the ADC data register
- Then I write directly to the ADST bit again to start the next conversion
This process should be fast and not tie up the processor in the timer ISR routine.
I would like help with the following:
- Is this proposal a good idea and can I make it work this way?
- Do I set up my adc in HAL_COMMON?
- Does this automatically "open" during power on init? I.e. are all the registers set up per my configuratoin?
- How do I write/read a register directly under Synergy, ISDE? Example instruction please. Ideally some fast simple way since I am in a very fast ISR routine.
As always thanks for your input and help.
Steve D.