HVP-MC3PH - How to measure signals with ADCB ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HVP-MC3PH - How to measure signals with ADCB ?

Jump to solution
1,477 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

I am able to make measurements over the ADCA.

Specifically, I have currently used:

ADCA_CH0 - Index 0 -> Vin

ADCA_CH1 - Index 1 -> U_dcb

ADCA_CH6B - Index 2 -> Voltage at TxD1 (potentiometer connected)

ADCA_CH2 - Index 3 -> I_phA

However, as soon as I want to measure something with ADCB (e.g., I_phB on ADCB_CH2 with Index 4), the whole thing does not work anymore.

If I load the sample projects of course it works, but I do not want to use all the configured ADC channels.

Perhaps the indexing in my own model is wrong ?

What I have to configure if I want to read signals with both ADC ?

 

0 Kudos
1 Solution
1,129 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

We have modified your example and we were able to successfully read some ADCB converted values with Freemaster, so I attached the modified example. If you will run it, please be aware that in order to read data using Freemaster we had to change your fault PTE1 pin with PTE2 (PTE1 is the TxD pin on UART1 used by Freemaster).

To answer your question, the Index from the ADCB must start from the value 8. So all ADCA channels must be consecutively indexed between 0 to 7, while the ADCB channels must have an index between 8 and 15. In your case the indexes should look like this:
(0, 8) - ANA0,ANB0
(1, 9) - ANA1,ANB1
(2,10) - ANA6,ANB6
(3,11) - ANA2,ANB2
(4,12) - ANA3,ANB3

Now, after we changed your indexing we found the following issues:

Simulink generates the code by ordering the blocks after some priorities that can be edited by right clicking the block and adding a number like in the figure 1. 

pastedImage_1.jpg

Fig. 1. Changing the Block priority

In your model, the conversions were scheduled like in the figure 2. The program was waiting to get the value from the channel ADCA_CH6B(priority 16) but the ADC_Start2 block was never called (priority 55) so no conversion was started. This was happening because some blocks had some priorities, others none.

prio_bad.JPG

Fig. 2. Bad block priorities

The ADC should work like this: the ADC_Start0 must tigger a conversion and after it is done, the blocks under the ADC_Start0 must put the values in V_in and U_dcb/2 values. Next the ADC_Start1 triggers another conversion and so on. We reordered the blocks like in the figure 3. 

prio_ok.JPG

Fig. 3. Reordered blocks priorities

Now, we found another problem caused by the IAR compiler, which reordered some program lines while otimizing the code. We fixed this by changing the optimization -Oh flag with   -Ol or completely removing it. To test this you can change it on the Target Compiler Opts as in figure 4. 

ol.JPG

Fig. 4 Changing the optimization flag

Finally, we were able to read some converted values using Freemaster.

free masterre.JPG

Fig 5. Freemaster reading ADCB values.

Hope that helps!

Marius

View solution in original post

0 Kudos
7 Replies
1,129 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi lethuer‌,

Sorry for long response delay. Have you fix this ? Do you still need help on this ?

Thank you!

Daniel

0 Kudos
1,129 Views
lethuer
Contributor V

I still need help.

What I have to configure if I want to measure some signals in parallel simultaneous mode ?

0 Kudos
1,129 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

For testing we used kv4xf_adc_parallel_simult.mdl example from Toolbox and it seems to be working(A&B ADC). Can you please send us your model to reproduce the scenario?

Best Regards, 

Marius

0 Kudos
1,129 Views
lethuer
Contributor V

Hi,

here it is.

The build report is successful but the code on the target doesn't start.

So also the communication with FreeMASTER doesn't work.

I don't really know which rules I have to account for indexing the ADX samples.

The example you have tried has three sample pairs:

(0,8) - ANA0,ANB0

(1,9) - ANA1,ANB1

(2,10) - ANA2,ANB2

I have configured this pairs with the same channels ob ADCA and ADCB like in the example.

(0,5) - ANA0,ANB0

(1,6) - ANA1,ANB1

(2,7) - ANA6,ANB6

(3,8) - ANA2,ANB2

(4,9) - ANA3,ANB3

I think that each sample pair principle could be configured totaly free.

So is it possible to read one pair with different channels at ADCA and ADCB or have they to be the same?

For example I want to read this two pairs:

(0,1) - ANA1 (U dcb), ANB2 (I phB)

(2,3) - ANA2 (I phA), ANB3 (I phC)

Which meaning has the index number in the ADC_Sample block or can I choose it free (of course I have to choose the correct Index in the ADC-Read block) ?

0 Kudos
1,130 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

We have modified your example and we were able to successfully read some ADCB converted values with Freemaster, so I attached the modified example. If you will run it, please be aware that in order to read data using Freemaster we had to change your fault PTE1 pin with PTE2 (PTE1 is the TxD pin on UART1 used by Freemaster).

To answer your question, the Index from the ADCB must start from the value 8. So all ADCA channels must be consecutively indexed between 0 to 7, while the ADCB channels must have an index between 8 and 15. In your case the indexes should look like this:
(0, 8) - ANA0,ANB0
(1, 9) - ANA1,ANB1
(2,10) - ANA6,ANB6
(3,11) - ANA2,ANB2
(4,12) - ANA3,ANB3

Now, after we changed your indexing we found the following issues:

Simulink generates the code by ordering the blocks after some priorities that can be edited by right clicking the block and adding a number like in the figure 1. 

pastedImage_1.jpg

Fig. 1. Changing the Block priority

In your model, the conversions were scheduled like in the figure 2. The program was waiting to get the value from the channel ADCA_CH6B(priority 16) but the ADC_Start2 block was never called (priority 55) so no conversion was started. This was happening because some blocks had some priorities, others none.

prio_bad.JPG

Fig. 2. Bad block priorities

The ADC should work like this: the ADC_Start0 must tigger a conversion and after it is done, the blocks under the ADC_Start0 must put the values in V_in and U_dcb/2 values. Next the ADC_Start1 triggers another conversion and so on. We reordered the blocks like in the figure 3. 

prio_ok.JPG

Fig. 3. Reordered blocks priorities

Now, we found another problem caused by the IAR compiler, which reordered some program lines while otimizing the code. We fixed this by changing the optimization -Oh flag with   -Ol or completely removing it. To test this you can change it on the Target Compiler Opts as in figure 4. 

ol.JPG

Fig. 4 Changing the optimization flag

Finally, we were able to read some converted values using Freemaster.

free masterre.JPG

Fig 5. Freemaster reading ADCB values.

Hope that helps!

Marius

0 Kudos
1,129 Views
lethuer
Contributor V

Hi @Marius Lucian Andrei,

thank you, that was very helpfull !

 

We have modified your example and we were able to successfully read some ADCB converted values with Freemaster, so I attached the modified example. If you will run it, please be aware that in order to read data using Freemaster we had to change your fault PTE1 pin with PTE2 (PTE1 is the TxD pin on UART1 used by Freemaster).

This is because I use UART0 Pins PTD6 and PTD7 for FreeMASTER communication.

The Jumper setting is like it is described in the user guide. So I can connect a potentiometer at J2_TxD

NXP Jumper.PNG

FreeMASTER UART0.PNG

The model you have modified runs successfully !

Simulink generates the code by ordering the blocks after some priorities that can be edited by right clicking the block and adding a number like in the figure 1.

Is there a reason for starting with priority 10 ?

For example the PWM_Three_Phase_Output has the same priority 10.

How can I synchronize the ADC conversation with the PWM Output Block, so that the conversation definitly isn't started in the rising or falling edge ?

0 Kudos
1,129 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi lethuer‌,

There is no particular reason of starting with 10. All you need to consider is the order to blocks execution in Simulink. The order should follow the logical flow and you can alter that based on block priorities.

Sometimes Simulink may consider a different order that in case of embedded system may lead to errors.

Please have a look here: https://community.nxp.com/message/941909?commentID=941909%23comment-941909#comment-899761  for an example. 

I got used to check the order of execution each time prior to code generation since i run in that kind of trouble too many times. Use CTRL+D to check the order prior of building the code.

Best regards,

Daniel

PS: for the second question, i've branched the discussion.

0 Kudos