Jump to content
Sign in to follow this  
sdujolo

Little Confused!

Recommended Posts

Hi,

 

I have a project on a PIC18 I use both low and and normal interrupt. I have a EUSART interrupt, A/D Converter Interrupt, timer0 interrupt to read temperature from ds18s20. I the main loop I check for diffrent status that happen in the interrupt rutins.

 

How to use Novo RTOS how to for example use serial comunication, read analog inputs on intrrupt, read tempature for exapmle every 2sec?

 

Regards /Jörgen

Share this post


Link to post
Share on other sites

Jörgen,

I have a project on a PIC18 I use both low and and normal interrupt. I have a EUSART interrupt, A/D Converter Interrupt, timer0 interrupt to read temperature from ds18s20. I the main loop I check for diffrent status that happen in the interrupt rutins.

 

How to use Novo RTOS how to for example use serial comunication, read analog inputs on intrrupt, read tempature for exapmle every 2sec?

The application needs to be split down into that which need hard real time reponse, and that which is more forgiving. Like does the temperature need to be read at precise time intervals, or just regularly?

 

Regards

Dave

Share this post


Link to post
Share on other sites
Jörgen,
I have a project on a PIC18 I use both low and and normal interrupt. I have a EUSART interrupt, A/D Converter Interrupt, timer0 interrupt to read temperature from ds18s20. I the main loop I check for diffrent status that happen in the interrupt rutins.

 

How to use Novo RTOS how to for example use serial comunication, read analog inputs on intrrupt, read tempature for exapmle every 2sec?

The application needs to be split down into that which need hard real time reponse, and that which is more forgiving. Like does the temperature need to be read at precise time intervals, or just regularly?

 

Regards

Dave

 

Hi Dave,

 

The temperature is does not need to be precise just regulary it´s more how I should deal with serial comunication and the analog-in that need to be read all the time and check the if there are between right intervals.

 

Regards /Jörgen

Share this post


Link to post
Share on other sites

Jörgen,

The temperature is does not need to be precise just regulary it´s more how I should deal with serial comunication and the analog-in that need to be read all the time and check the if there are between right intervals.
So analog needs to be read and processed at precise times as well ?

 

Regards

Dave

Share this post


Link to post
Share on other sites
Jörgen,
The temperature is does not need to be precise just regulary it´s more how I should deal with serial comunication and the analog-in that need to be read all the time and check the if there are between right intervals.
So analog needs to be read and processed at precise times as well ?

 

Regards

Dave

 

At the moment I have it in the low interrupt like the code below I use it for checking alarm so it´s kind of importen.

 

Regards /Jörgen

 

CODE
if ( test_bit(pir1, ADIF) ) //A/D Converter Interrupt Flag bit

{

char i;

short retval;

char temp = 0;

static char channel = 0;//Channel to do next.

char active_channel; //The channel that has the current analog value.

 

if( channel == 0 )

active_channel = MAX_ANALOG_INPUT-1;

else

active_channel = channel-1;

 

 

retval = (short)adresh;

retval = retval << 8;

retval |= adresl;

 

analog_in[active_channel] = retval;

 

if( (active_channel < nr_of_alarm_input) && alarm_on ) {

for( i = 0; i < NR_OF_ALARM_ZONE; i++ )

{

if( (test_bit(activated_zones, i)) && (test_bit(alarm_zone_inputs, active_channel)) && ( !(test_bit(alarm_delay_input, active_channel) && alarm_delay_counter) ) )

{

if( retval < 50 )

{

if( !alarm )

alarm_delay_counter = alarm_delay;

 

alarm_status[active_channel] = 2; //Sabotage alarm

alarm_zone = i+1; //Zone that is in alarm

//Printf("Sabotage larm channel=%d", active_channel + 1);

}else if( (retval < (normal_alarm_level-alarm_threshold)) || (retval > (normal_alarm_level+alarm_threshold)) )

{

if( !alarm )

alarm_delay_counter = alarm_delay;

 

alarm_status[active_channel] = 1; //Alarm

alarm_zone = i+1; //Zone that is in alarm

//Printf("Larm channel=%d", active_channel + 1);

}

}

}

}

 

clear_bit(adcon0, CHS0); //Clear channel

clear_bit(adcon0, CHS1);

clear_bit(adcon0, CHS2);

clear_bit(adcon0, CHS3);

// Shift the channel value to the appropriate position

temp = (channel & 0x07) << 2;

// And move it to the appropriate position in adcon0

adcon0 |= temp;

 

//Printf("Channel=%d\r\n", active_channel);

//Printf("ADC=%d\r\n", retval);

 

if( channel < (MAX_ANALOG_INPUT-1) )

channel++;

else

channel = 0;

 

temp = channel;

 

 

clear_bit( pir1, ADIF ); //Clear A/D Converter Interrupt Flag bit

adc_go = 1; //Start analog measure

}

Share this post


Link to post
Share on other sites

Jörgen,

At the moment I have it in the low interrupt like the code below I use it for checking alarm so it´s kind of importen.
Sorry for not comming back with an answer.

More knowledge of the application is required.

 

Maybe I'll bash out what I think you need.

Is the monitoring of the AD values and alarms time crtical? (I would guess not).

 

Regards

Dave

Share this post


Link to post
Share on other sites
Jörgen,
At the moment I have it in the low interrupt like the code below I use it for checking alarm so it´s kind of importen.
Sorry for not comming back with an answer.

More knowledge of the application is required.

 

Maybe I'll bash out what I think you need.

Is the monitoring of the AD values and alarms time crtical? (I would guess not).

 

Regards

Dave

 

I don´t know how critical it is am have not tested how fast it had to be read yet.

I like to do something like this...

 

1 Serial communication to receive commands, settings and sending alarms, status ect... (critical)

2 Reading temp (not critical)

3 Read analog-in and check alarm limits(critical)

4 Check temp values are in correct limits(not critical)

5 Read/Write EEPROM on settings change

6 Data from SPI(critical)

 

Hope it make some sense?

 

Regards /Jörgen

Share this post


Link to post
Share on other sites

Jörgen,

 

I think you need to describe the application a little more, I can see the analogues and alarm bits are related, but I don't fully see how.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Jörgen,

 

I think you need to describe the application a little more, I can see the analogues and alarm bits are related, but I don't fully see how.

 

Regards

Dave

 

Hi Dave,

 

Is not actual programing that´s a problem is how to strcuture the the diffrent task to use it wiht novo RTOS. I have working beta version whit out novo now.

 

Best regards /Jörgen

Edited by sdujolo

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...