PWM Values showing wrong?

Related to the Portal
Post Reply
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

PWM Values showing wrong?

Post by TanksNStuff »

I've recently got my RA online with my tank and was just looking at the web portal to review the status of my tank. I noticed something strange and was wondering if this is an issue with the portal itself or with my controller/wifi sending incorrect data?

Image

It obviously can't be over 100%, right? Only thing I can think of is that it might be due to Roberto modifying my PWM module to send an analog signal instead of PWM.

Any ideas?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Values showing wrong?

Post by rimai »

I think you've got wrong internal memory settings.
Can you check them?
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: PWM Values showing wrong?

Post by TanksNStuff »

I'm not at home at the moment. Is there any way I can check remotely? I have wifi.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Values showing wrong?

Post by rimai »

Android.
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: PWM Values showing wrong?

Post by TanksNStuff »

Android doesn't show PWM Channels though. I can check my pwm slope start% and end%, that's about it.

I just checked those and I come up with this:

PWM Slope Actinic Start % = 25
PWM Slope Actinic End % = 50
PWM Slope Daylight Start % = 20
PWM Slope Daylight End % = 50

Also, since you'll probably ask next... I checked these. I'm not using the 2 channels on the main relay box though, so don't need them :

Actinic PWM Value = 0
Daylight PWM Value = 0
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Values showing wrong?

Post by rimai »

What function are you using for the slope on the expansion module?
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: PWM Values showing wrong?

Post by TanksNStuff »

Just noticed something else, after reviewing my last post.

My slope end%'s are both at 50%.
50% of 255 (max of range for those memory locations) is 127.5
Portal is showing 127.

Could it be that the portal doesn't convert to % or is that just a coincidence?

I know I had a similar issue with the display on my controller. Curt modified my code to show it as a % value instead of the integer and it looks correct on my controller now.

Here's my code for the PWM Slope (I omitted everything except the PWM stuff):

Init section -

Code: Select all

//--------------------------------------------------- Start of Global Variables ---------------------------------------------------
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5

// Initial values to all 6 PWM channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
Loop section -

Code: Select all

void loop
//------------------------------------------------ Start PWM Expansion Code for Slope ----------------------------------------------
    //  Temporarily using Memory Locations from PWM Slope Actinic (for LEDPWM0 and LEDPWM1) and 
    //  PWM Slope Daylight (for LEDPWM2 and LEDPWM3) for the start, end, durations.
    //  Will change the start%, end%, duration of each to new memory locations for each channel when Curt provides libraries update.
    PWMChannel[LEDPWM0]=PWMSlope(
      InternalMemory.StdLightsOnHour_read(),
      InternalMemory.StdLightsOnMinute_read(),
      InternalMemory.StdLightsOffHour_read(),
      InternalMemory.StdLightsOffMinute_read(),
      InternalMemory.read(852),  // start %
      InternalMemory.read(853),  // end %
      InternalMemory.read(854),  // duration
      PWMChannel[LEDPWM0]);
      
    PWMChannel[LEDPWM1]=PWMChannel[LEDPWM0];

    PWMChannel[LEDPWM2]=PWMSlope(
      InternalMemory.MHOnHour_read(),
      InternalMemory.MHOnMinute_read(),
      InternalMemory.MHOffHour_read(),
      InternalMemory.MHOffMinute_read(),
      InternalMemory.read(849),  // start %
      InternalMemory.read(850),  // end %
      InternalMemory.read(851),  // duration
      PWMChannel[LEDPWM2]);

    PWMChannel[LEDPWM3]=PWMChannel[LEDPWM2];

    // The lines above are what calculates the slope.
    // You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
    // The are as follow:
    // 1st parameter: hour to start slope
    // 2nd parameter: minute to start slope
    // 3rd parameter: hour to end slope
    // 4th parameter: minute to end slope
    // 5th parameter: % of the PWM signal to start slope
    // 6th parameter: % of the PWM signal to end slope
    // 7th parameter: duration of slope in minutes
    // 8th parameter: always the same as the variable before the PWMSlope() call

    //PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);

    // In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
    // Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
    // Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
    //CheckCloud(); (May be used at a later date with cloud/storm effects)
    ReefAngel.PWM.Expansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
    ReefAngel.PWM.Expansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
    ReefAngel.PWM.Expansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
    ReefAngel.PWM.Expansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
    ReefAngel.ShowInterface();

//------------------------------------------------- End PWM Expansion Code for Slope ----------------------------------------------
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Values showing wrong?

Post by rimai »

Remove the 2.55 multiplication on all channels. That is what is causing it to go to 127
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: PWM Values showing wrong?

Post by TanksNStuff »

OK, I'll try that tonight. Thanks Roberto.

I'm guessing that once I do that I'll also have to change my custom main code too. If it looks strange after the change, I'll fix that too.
Post Reply