¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Projector module issue with CP3 but not with MC3 #programming #simpl #simplwindows #cp3 #crestron


 

Hello,?
? ? Here's my issue: I have an old ViewSonic PRO-8100 connected via RS-232 (port 2) which controlled the power off & on, showed me the lamp hours on my touch panels (Projector on...Lamp hours: 105) through a user module when the MC3 was connected (which I still have). Now I have a CP3 installed and the message on the touch panel says Projector on...Lamp Hours: 0 but the power off & on still functions (still RS-232 port 2), so the CP3 isn't seeing the lamp hours information.
?
Is there a difference in the way that the serial ports receive data between the MC3 and the CP3?
?
Donald


 

If you want to see the code from the module, here it is:
?
#SYMBOL_NAME "ViewSonic PRO 8100 Parser and Poller"
#CATEGORY "24" // Misc
#DEFINE_CONSTANT POLL_INTERVAL 3000 // 5 minutes in tenths of seconds
#DEFINE_CONSTANT WARM_TIME 1200 // 2 minutes in tenths of seconds
#DEFINE_CONSTANT COOL_TIME 1800 // 3 minutes in tenths of seconds
DIGITAL_INPUT Poll, Power_On, Power_Off;
STRING_INPUT FromDevice$[255];
ANALOG_OUTPUT LampHours;
DIGITAL_OUTPUT Warming_FB, Cooling_FB;
STRING_OUTPUT ToDevice$, ToTouchPanel$;
INTEGER iLampHours;
INTEGER iState; // 0: Off, 1: Warming, 2: Cooling, 3: On
INTEGER iWarmCoolTimer;
INTEGER iPollTimer;
FUNCTION UpdateStatus()
{
? ? STRING sStatus[50];
? ??
? ? IF(iState = 1)
? ? ? ? sStatus = "Lamp warming up... ";
? ? ELSE IF(iState = 2)
? ? ? ? sStatus = "Lamp cooling down... ";
? ? ELSE IF(iState = 3)
? ? ? ? sStatus = "Projector on... ";
? ? ELSE
? ? ? ? sStatus = "Projector off... ";
? ??
? ? ToTouchPanel$ = sStatus + "Lamp Hours: " + ITOA(iLampHours);
}
CHANGE FromDevice$
{
? ? IF (LEN(FromDevice$) >= 5 && LEFT(FromDevice$, 2) = "\x1E\x00" && RIGHT(FromDevice$, 2) = "\x00\x00")
? ? {
? ? ? ? iLampHours = BYTE(FromDevice$, 3);
? ? ? ? LampHours = iLampHours;
? ? ? ? UpdateStatus();
? ? }
? ? CLEARBUFFER(FromDevice$);
}
FUNCTION PollLampHours()
{
? ? ToDevice$ = "\xBE\xEF\x1A\x0C\x00\x56\x6A\x52\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00";
}
FUNCTION HandleWarmingCooling()
{
? ? IF(iState = 1 || iState = 2)
? ? {
? ? ? ? iWarmCoolTimer = iWarmCoolTimer - 1;
? ? ? ? IF(iWarmCoolTimer <= 0)
? ? ? ? {
? ? ? ? ? ? IF(iState = 1)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Warming_FB = 0;
? ? ? ? ? ? ? ? iState = 3;
? ? ? ? ? ? ? ? PollLampHours(); // Poll immediately after warming up
? ? ? ? ? ? }
? ? ? ? ? ? ELSE
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Cooling_FB = 0;
? ? ? ? ? ? ? ? iState = 0;
? ? ? ? ? ? }
? ? ? ? ? ? UpdateStatus();
? ? ? ? }
? ? }
}
PUSH Power_On
{
? ? iState = 1;
? ? Warming_FB = 1;
? ? iWarmCoolTimer = WARM_TIME;
? ? UpdateStatus();
}
PUSH Power_Off
{
? ? iState = 2;
? ? Cooling_FB = 1;
? ? iWarmCoolTimer = COOL_TIME;
? ? UpdateStatus();
}
FUNCTION Main()
{
? ? iPollTimer = POLL_INTERVAL; // Initialize poll timer
? ? WHILE(1)
? ? {
? ? ? ? HandleWarmingCooling();
? ? ? ??
? ? ? ? IF(iState = 3)
? ? ? ? {
? ? ? ? ? ? iPollTimer = iPollTimer - 1;
? ? ? ? ? ? IF(iPollTimer <= 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? PollLampHours();
? ? ? ? ? ? ? ? iPollTimer = POLL_INTERVAL;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ??
? ? ? ? DELAY(10);
? ? }
}
PUSH Poll
{
? ? IF(iState = 3)
? ? {
? ? ? ? PollLampHours();
? ? ? ? iPollTimer = POLL_INTERVAL; // Reset the poll timer
? ? }
}

?
Donald


 

This is a complete guess but here goes¡­
1. since commands work, you know your com spec is ok, and com ports are com ports - they don¡¯t work differently on different devices so I wouldn¡¯t think that¡¯s a problem
2. the mc3 and cp3 have different physical serial connectors - d-sub vs phoenix. Have you triple checked the Rx wiring? It¡¯s trivial on the phoenix so I¡¯m assuming that¡¯s also not the issue - but worth checking. ?Do you see data arriving in SIMPL Debugger? ?That¡¯s the acid test.
3. So - my initial theory: ?the CHANGE event might be your problem. ?Rather than gathering data, the event is triggering on every change, and clearing the input each time. ?First off, the input is defined as a STRING rather than a BUFFER. The code was written assuming at each RX packet would arrive on a single logic wave - this is simplistic and may well work on slower processors (2-series, MC3) but faster devices will present the RX data as it arrives, potentially a byte at a time. ?This will cause the current implementation to never process a packet => no lamp hours.
?
in short, the FromDevice$ input should be a BUFFER_INPUT and the change handler needs re-writing to wait for a full packet before processing (and not clearbuffer on every change)
?
like I say though, that just a guess!
Oliver


 

I should say; the module has other issues (the whole polling, warm/cool state timers are pretty nasty¡­) but that¡¯s more an approach thing - it¡¯ll work, it¡¯s just not a great solution.


 

Oliver -?
? ?I did check the phoenix wiring (the projector does turn on & off) and I even moved the phoenix connection from Com2 to Com1 (no change there). Simpl Debugger does show data arriving.
Lastly, the module was written by AI, so I will see what I can do about your CHANGE event, BUFFER_INPUT theories.
?
Donald


 

On Sat, Apr 26, 2025 at 08:25 AM, dsmith wrote:
Lastly, the module was written by AI
I think that there's a joke here...:)


 

Not a very good joke though :-/


 

Just a word of advice regarding the use of AI to write Simpl+ for you. ?Take it or leave it. ?Since Simpl+ is poorly documented and is a proprietary language, the AI does not have enough data to do a good job at writing S+ code for you. ?My experience with it when I tried is that it seldom even got the syntax right, let alone best practices. ?You¡¯re better off learning the language and doing it yourself.
?
Btw, Oliver¡¯s advice is spot on. ?Use some type of gather on a buffer input depending on how the device sends the data.
?
Dean


 

On Sat, Apr 26, 2025 at 11:20 AM, Oliver Hall wrote:
Not a very good joke though :-/
agreed...


 

:)
?
Seriously, AI wrote my code for the MC3 for the parsing and polling for my projector, it was trial and error. Since I knew what I wanted the code to do (but I don't know Simpl+), I would try the code, tell AI nope, here's the error I got and it took weeks but finally, it worked.
?
Dean, I will take your advice and try slowly to write some code on my own (baby steps....? :)? )