Homebrew BACnet/IP integration


#1

This stems back from a post regarding BACnet/IP in Feb
http://www.opto22.com/community/showthread.php?t=103

I was needing a BACnet/IP solution for integrating to a Mitsubishi VRF system with their BAC-HD150 device. From tmcculloh’s reply i could have purchased a S2 and a BASRT-B router, get the integration kit from the Opto22 site and that would provided an adequate solution. The reason i did not pursue this path was the high price of controllers, limited budget, no need for full BACnet integration and we already have some 13 controllers on the hospital site (all S1’s and R2’s). plus i knew that more BACnet systems were being installed in future and i was hoping to utilize the existing controllers and their Ethernet connections.
So after cutting my teeth on the VRF interface i got the hang of BACnet (as much as i needed to get me out of trouble ;)) and just recently had to interface to some Trane chillers. The chillers were MS/TP and after deciding to stick with BACnet/IP, lashed out and brought a BASRT-B router (thanks tmcculloh. very neat device, and cheap!).

I cleaned up the existing BACnet code i had and have provided a sample strategy with some subs attached to do some simple discovering, reading and writing of devices on a BACnet/IP network. It works really well with gateways or routers, not really sure about individual devices.

the level of integration is very basic, fairly rigid and rough (just like homebrew :p) and really should be used for interrogating the BACnet network for data and the occasional write. i have been using similar code for the Mitsubishi VRF system since march and it has not been a problem. just keeps on getting and setting the data.

if you have some BACnet/IP stuff that you need to get data in and out of without getting too heavy then this may help.

Definitely a little more than a snippet but i kinda thought code like this may be worth something to someone out there. And it might provide a decent enough base for someone to build on for their own requirements (hopefully opto22 will provide a BACnet/IP integration kit soon??).

I hope this is OK to upload a sample strategy?

nick


#2

This looks cool. Even though using a BACnet router works, it is very limited. Thanks again Nick, will comment future once I get a chance to try it out.


#3

Wow, Nick, this is excellent! Uploading sample strategies is not only OK, it’s strongly encouraged.
Extra gold stars for including lots of comments, some lovely subroutines and such useful functionality!
Many mahalos and thank yous.
-OptoMary


#4

no problems guys. i wasn’t sure if strats were allowed, now i know i might have to start uploading more!!

rcoburn, let me know if you do have a crack at it. i would appreciate some feedback to see if it was pretty simple and easy to implement (and if it just worked). when yr knee deep in coding, sometimes what makes sense to you doesn’t really make sense to anyone else.

oh yeah, btw this strat has been compiled using PAC Control Pro 9.0g. Sorry forgot to do it using PAC Control Basic…

nick


#5

Nick,

Wanted to let you know that I’ve now had an opportunity to really put this through its paces and it is remarkable. Opto22 needs to capture you, lock you in a room, feed you beer and pizza, and let you develop it into the next release of their Bacnet integration kit.

Cheers!


#6

Wanted to let you know that I’ve now had an opportunity to really put this through its paces and it is remarkable. Opto22 needs to capture you, lock you in a room, feed you beer and pizza, and let you develop it into the next release of their Bacnet integration kit.
Mmmm beer and pizza… well it beats working for peanuts (and i’ve done that before)!!

Well I take it that it worked OK? Hopefully it was pretty easy to get up and running. Thanks for the kudos and I’m glad it helped.

Hopefully we do see a Bacnet/IP release by Opto22 in the future (minus a beer filled pizza fed Aussie):stuck_out_tongue:


#7

Update…
Here is an update. i used it on a Trane BACnet/IP interface device the other day and found a bug. seems it worked fine when routing to another network but not if you are not…

anyway use these subs instead of the original ones and keep the good times rolling!! :cool:

Nick

BACnetIP homebrew-V2.zip (29.2 KB)


#8

When i developed these BACnet subs they worked fine on the application they were designed for. Now that i am reusing them for a new installation, some cracks appeared…
so i rolled up the sleeves, pulled out the ‘No More Gaps’ and got to work (i’m sure there are more cracks that i haven’t seen yet…)

the app i am working on doesn’t do segmented replies therefore causing an error and getting no data. i was fetching 45 analog input values and i could get about 27 before it bombed out. so i checked a few things and changed the max reply length to 1024 (i think for bacnet/ip its 1400andsomething. but i don’t think i can have a string length greater than 1024 in Opto?) but this didn’t work. so i then decided to chunk the requests into 20 instances long to solve this.

i also found an error when specifying the length, fixed that too.

so here is an update for anyone who might be using it (or have thrown it out because it didn’t work…)

BACnetIP homebrew-V2.1.zip (28.8 KB)

Nick


#9

Hi Nick,

Re: your question about having a string larger than 1024. The short answer is “no.” However, there are other ways of storing longer data.

For example, on that example I shared this summer to get the weather from weatherunderground.com (by doing a “scrub” of the page), the data coming back was more than 1024 characters. But I wanted it in one piece so I could search for certain strings that preceded the data of interest.

So, I [B]stored all the data coming back in a temporary file[/B]. Then, I could make use of some of the file comm handle commands like “find” to search the whole temp file for a particular string. The command looks like this:

nPosOffset = SendCommunicationHandleCommand(chTempFile, “find:<title>Weather Underground”);

Perhaps you could use a technique like that for temporarily storing your > 1024 characters?

-OptoMary


#10

AH_HA! You have just solved a conundrum I had.

Scratchpad strings are limited to a total of 64, now if I use a file on the SD card for the less time critical strings…


#11

yeah mary, very nice solution. i like it, very neat way to get and sift large amounts of data. turn your file storage area into a ‘temp’ directory.

any idea if Opto are going to release a full BACnet/IP integration pack??


#12

Hi CeeJay,

I’m glad I could help with your conundrum! Something else to ponder – since you mentioned the scratchpad and time/speed – writing to the SD card IS slower than writing to the built-in file area of the PAC.

I’m guessing you need more than the 0.3 - 2.5MB of file storage in flash memory or 2 - 16MB of volatile file data storage, hence the SD card? (See this tech note, form 1646, for more details on available memory and file space).

Also, although the [B]scratch pad STRINGS are limited to a total of 64 bytes, there’s nothing to prevent you from using other areas of the scratchpad to write bigger strings[/B] – you’ll just have to carefully keep track of their address and length. This is very fast.

For example, if I’m not using the (now huge) scratch pad area normally used for integers, I can write a string in there at the mem map is none the wiser, it’s just storing bytes.

I could use this command and give it the address of scratch pad int [0]:

nResult = WriteStrToIoUnitMemMap( self, 0xF0D81000, sMyString );

I can even have PAC Man interpret that area of the mem map as a string if I use the generic read/write option:


Since the scratch pad string area stores the length of the string for you (in the 2 bytes that precede the actual string), you might choose to do something similar in your free-form mem map writing (although I’d recommend using 4 bytes, even if you don’t need all that, since PAC Control integers are 4-bytes).

In any case, I hope I haven’t totally confused you. Just throwing out some ideas/options for you here.

-OptoMary


#13

Thanks Mary, looks interesting and the writing to the impressively big Integer area would definitely satisfy our needs while leaving the other standard memory available as usual!


#14

Nick,

re:

full BACnet/IP integration pack

I asked our integration kit guru about this, he said: “I use a BACnet/MSTP to BACnet/IP router. It’s about $300.” He also mentioned how the router helps iron out some icky (my word, not his) requirements of the protocol.

So the short answer is “no” but I thought I’d share about that router for those doing BACnet out there.

-OptoMary