First Module...Newbie
vegastech
Posts: 369
I finished P1 a month or so ago and I finally have a functioning system at home that I can play with. I downloaded the JVC LCD Duet 232 module and loaded it and the TP file on my system. However, since this is my first time using a module, can you folks give me some pointers? I was going to add some channel events for button presses (that's what the module calls for), but I can't seem to get started, other than this:
Channel_Event [dvTP,9]
{
PUSH:
{
PULSE,
}
}
What do I need to add in order to get a button press to send a command via the 232 port?
I have loaded the duet firmware on my ni-700 already.
Channel_Event [dvTP,9]
{
PUSH:
{
PULSE,
}
}
What do I need to add in order to get a button press to send a command via the 232 port?
I have loaded the duet firmware on my ni-700 already.
0
Comments
The instruction file that came with the module should tell you what each channel does, and if it's an on/off type control or a pulse type control. Many modules also recognize send_commands and/or send_strings.
Both the channel controls, send_commands, and send_strings go in the button_event (or in any other type of event), in the section of the event that corresponds to when you want the command to execute.
Hope that helps.
I think the module documentation is referring to the type of event the module is watching for on the virtual device. I can see how it could be a bit confusing if you've never used a module before though. There were certainly some things that confused me for a bit the first time I used one.
1, send a string directly to a device to do something.
2, send a command to a module to have the module send a string to a device.
3, set a virtual channel on/off (usually pulse on so it resets to off automatically) to cause the module to send a string to the device.
Of course not all button pushes are going to result in a string being sent to a device but instead handle logic, set flags or what have you but for the sake of this discussion let's assume that the result of a TP button push is to send a string to a device.
Typically most newer modules will use channel_events to trigger the module to send a string. Push a button on a TP which triggers a button_event in the master and in the code for this button number you pulse a virtual channel. This pulse sets the virtual channel on then resets to off (so it can be turned on again later). Now in the module they'll use a channel_event instead of a button_event which will see the channel go on and execute the code for that channel number which in our case will send some string to our device to do something.
--John
Anyway, I have been successful in getting 232 control to work, however intermittently. I think I have forgotten to initialize the port on my NI for the proper 232 settings. Does this look right for the netlinx programming?
DATA_EVENT[dvDVD2]LCD
//Data Event for LCD Serial Control
{
ONLINE:
{
SEND_COMMAND dvLCD,"'SET BAUD 19200,O,8,1'"
}
}
Kidding aside, of course you should get consistent results, otherwise what's the point.
You should set up your own buffer to see what's returning from the device but with duet modules you'll need to use the "PASSBACK" command otherwise you won't get anything in your buffer even if you "CREATE_BUFFER" for that device. Also use diagnostics "device notifications" to watch what's being sent to the device. There should also be some debug command you can send to the module or set a channel to turn on which will print to the diagnostics windows things the programmer felt would be worth watching.
PASSBACK may or may not be implemented. Duet takes over the I/O, and standard buffers won't work, period. I don't think even direct commands to the port will work; it's going through the Java portion of the SNAPI router, and I don't think anything on the NetLinx side works unless the module specifically hooks it. If PASSBACK wasn't implemented, your only option is to physically connect to the port and monitor it.
Line 61 (09:15:13):: Command From [41001:1:1]-[XCH-36]
I had told the TV (via the module) to change to channel 36. The TV did not change, and I see this line repeating every 30 seconds:
Line 64 (09:15:13):: String To [5001:1:1]-[!$82$80CH36$0A]
Am I correct in assuming that this means that the TV is not responding in a timely manner, or that it is not receiving the correct code (based on perhaps an incorrect com port setting) and not functioning correctly? I find it interesting that first thing this morning I walked up to the TV, pressed the power on button on my TP, and it worked. I was able to press channel up 1 time, and then not again.
I do have about a 25 foot run of cat5 with rj45-DB9 adapters plugging into the tv and my ni-700. Should I move my controller closer, or is there something else I can do to check the setup of the TV, perhaps?
What TV are you trying to control? The ! (bang command) looks familiar but I don't recall what brand uses it. What's the module name? Might be easy for us to just take a look at it instead of guessing.
Now you're using CAT-5 w/ an RJ-45 to DB9 adapter so I'll go out on a limb and say we're talking an RS232 connection. 50' is the recommended max length while some references will say 5,000 feet at a low baud of 9600 is ok. Stick with the 50' especially when using non-shielded high capacitance wire.
Now I suppose it's possible that your TX line is properly connected but your RX line isn't. Maybe you're using too many pins. Most connection just need pins 2,3 & 5 and having other pins tied in will cause RX to fail. Now the fact that the module is sending repeatedly for what should be a single issue command would make me think that the module expects some sort of ACK (acknokledgement) response whether it be an actual ack, ok or an echo of the command sent. It's not getting one so it resends it.
You did say the power worked occasionally but the TV didn't respond to a channel change, hmmm.... Sounds like a mix of issues..
DATA_EVENT[dvJVC]
{
ONLINE:
{
SEND_COMMAND dvJVC, "'SET BAUD 19200,O,8,1'"
}
}
The TV requires 19200 baud, Odd parity (I rarely see this...),8 data bits, 1 stop bit, and uses ASCII for communication mode.
I decided to run a terminal emulator program on my pc to capture the commands coming from my ni processor. When I use a premade null modem cable, my commands come thru exactly as I have executed them in the programming. When I use the db9-rj45 adapters and a length of cat5, everything gets jacked up. I'll have to look at the cable and/or try new adapters to see if that helps. The downside is that I still cannot get the LCD to respond to 232 strings. I was able to begin to decode the protocol-it wants both ascii and hex, so I've got that figured out (I think) to a point. I can see my strings being output, but still no joy. I guess I will call JVC in the morning to try and determine if I may have issues with the 232 port or something else that I may be missing in the code structure.
FF FB 57 F7
While I see this when I use the null modem cable(s):
21 82 80 50 57 31 0A
Does that make me a better programmer than installer? Good thing it's at my house...
I've been doing this for many years. And it's always the same for me. There's just something about rs232 that I end up flubbing around with it before it works as advertised. I've actually just built it into the price. I always seem to end up futzing around with connections, terminations, port setup, settings on the device, programming, etc... And to be frank, it's funny how many times it just seems to start working magically for no known reason. rs232 has always been kind of a black art, in my opinion.
But I'm still having difficulty getting a 2,3,5 wire connection to work on this JVC LCD. The premade null modem cable works fine every time (extended with additional straight thru premades at about 25 feet). I tried to disassemble the premade null cable (I have extras),and it seems that pins 1 and 6 were shorted together along with the wire from pin 4. I tried to duplicate this, but still nothing. Has anyone been able to successfully control a JVC device (Projector, etc.) via 232 with only 3 wires? JVC support knows nothing other than where the serial protocol is posted on their website.
I got so tired of the various RJ45 - DB9 adapters with different pin outs I now usually just use these and leave them in permanently. Not to mention the earlier models that required soldering. It just isn't worth it, now if it doesn't work straight through it takes a 5 seconds to reverse pins 2 & 3 on one end.
That being said, I am working on getting variables, and therefore button presses, to work. I have my passthru commands working, but is it possible to set a variable in a Switch...Case scenario? I have a Sw/Case setup for my discrete power buttons, and I want to set my nTVPWR variable to 1 when ON, and 0 when Off. Can I do this in a Sw/Case setup, or should I use a different programming style for this?
hi guys i just want to ask, can i define constant with more than i numbers?
for example:
DEFINE_CONSTANT
ODD = 3, 5, 7
SERIES = 1, 2, 3, 5, 8
Thanks a lot
How can set a specific expression for IF ELSE statement..
for example:
send string if "nLevelValue" is greater than or equal to 224 but not less than or equal to 192
if i use the expression which is the last
IF(nLevelValue >= 224)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 12',$0D,$0A"
}
the system will send all the strings from the beginning of the if statements that has a lower value. please see may sample. any thoughts about this?? thanks
LEVEL_EVENT[dvMET,WHEEL_LVL]
{
IF([dvMET,1])
{
nLevelValue = LEVEL.VALUE
SEND_LEVEL dvMET, LED_LVL, nLevelValue
SEND_STRING 0,"'teller level is ',itoa(level.value)"
IF(nLevelValue >= 0)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 -2',$0D,$0A"
}
IF(nLevelValue >= 32 )
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 0',$0D,$0A"
}
IF(nLevelValue >= 64)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 2',$0D,$0A"
}
IF(nLevelValue >= 96)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 4',$0D,$0A"
}
IF(nLevelValue >= 128)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 6',$0D,$0A"
}
IF(nLevelValue >= 160)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 8',$0D,$0A"
}
IF(nLevelValue >= 192)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 10',$0D,$0A"
}
IF(nLevelValue >= 224)
{
SEND_STRING dvBiamp,"'SET 1 FDRLVL 17 1 12',$0D,$0A"
}
}
}
Note if you copy & paste this code these send strings are off from the original code and need to be fixed.
Just so happens I was playing with this yesterday and with what I've tried so far sending the level directly from the wheel (METKP LVL 2) back to the display (METKP LVL 1) works better than sending level to my autopatch, converting the AP's response and sending back to the METKP's display.
I used my left / right wheel scroll (btns 12,13) to set a var to qualify my level event but I also use this to block my feedback to the keypad from the autopatch. The display feedback is directly fed back to the keypad until the btn 12,13 are released and the qualifying var is set back to 0 and then the final display feedback is from the autopatch in a sense to confirm the display. I'll have to play with this some more since it does seem a bit convoluted and I ususally prefer to receive all FB from the device being controlled.
Outof curiosity how are other folks handling this level display feedback on the MET KP6Ns?
Button 1 of Met 6N located at room 1 is for light control, Button 1 of Met 6N located at room 2 is for light control and so on..
Button 2 of Met 6N located at room 1 is for light control, Button 2 of Met 6N located at room 2 is for Fan control and so on..
however for button 6 it has a common device for all to control, if keypad 1 is using button 6 the rest shouldnt be able to use their button 6 until keypad 1 press button 6 again to turn it off. the other user will know that someone is using the button 6 because the light on their button 6 is ON.
here's what i did, for keypad 1 and i need to write this on the rest of the keypad. Is there any other way to write this? thanks for the help.
BUTTON_EVENT[dvMET,6]
{
PUSH:
[dvMET,6] = ![dvMET,6]
IF (![dvMET,6])
{
ON [dvMET,6]
ON [dvMET2,6]
ON [dvMET3,6]
.......
ON[dvMET20,6]
CALL 'Default'
}
ELSE
{
OFF [dvMET,6]
OFF [dvMET2,6]
OFF [dvMET3,6]
.......
OFF[dvMET20,6]
CALL 'DEFAULT2'
}
}
I personally prefer varaible to tracking channels states since I feel it's easier to debug by dropping the var in the debug window rather that checking port status and refreshing all the time. Unless the system is so large you can't afford to waste vars that is.
You can get rid of the swtich case for nKP_Indx if using the index in the statement directly can get the job done. Use a look up table or just an array of lighting commands indexed to match the KP indexes.
What are you doing with button 6 anyway that makes it a first user has the use of it type of program?
i really appreciate your help. actually my program is for the 20 interview booth using biamp controlled by met 6N.
button 1 for interviewer mic select
button 2 for interviewee mic select
button 3 for interviewer mute button
button 4 for interviewee Mute button
button 5 for paging location 1
button 6 for paging location 2
Jog dial for volume control
let me attach my axs. to give you an idea on what am i talking about.
it is not really complicated at first in fact i was able to finish programming one keypad and make it functioning, but when i used more that 1 keypad it started to get more complicated. button 1 to 4 is not a big deal because it was assign on a different device regardless on what keypad you will use, however for the button 5 and 6 there is only 1 device to control for all keypad and obviously they cannot use it at the same time.
My problem is how can i link all button six so that if anyone use button six it will enable the rest of button 6 and others cannot use it until the first user press it again and disable the button six. im sorry for my question, this is my first module and i never thought it would be this complicated for me.