# Should I use Transaction Group for this?

**URL:** <https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988>\
**Category:** Ignition\
**Created:** [February 11, 2014, 7:44pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988 "2014-02-11T19:44:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 11, 2014, 7:44pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/1 "2014-02-11T19:44:12Z")

</div>

I have attached a screen shot of a db table I made…I need to check two columns in the table, Card Number and Pin number against 2 tags in my PLC. The PLC will have a Card Number & Pin Number stored to in to data registers that I will bring into Ignition and if those 2 PLC tags match Card Number & Pin Number in a row of the table I need it to write a value back to my PLC. Later on I will also need to make another database that stores the whole row of data that the Card Number and Pin Number matched with after it wrote back to the PLC…Like the Company, First Name, Last name…any help would be appreciated on best route for this.

![]()

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [February 11, 2014, 11:52pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/2 "2014-02-11T23:52:23Z")

</div>

you could use a transaction group with a where clause or scripting, which ever is easier for you to use. I would do the logic in scripting and then use the transaction group to store it in the db.

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 12:08am UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/3 "2014-02-12T00:08:46Z")

</div>

Maybe I should explain what this will be doing to begin with I guess. Basically this will be used at a Waste Water Disposal in the Oil and Gas Industry. Our customer will enter all their customers, drivers names and card and pin number that belongs to each driver. Then I have PLC’s programmed a long with an HMI on site. They scan the card and the number is stored to the PLC, then they input their pin number on the HMI which is also stored to the PLC if it matches the Card and Pin Number in a row of the table database our customer created it will allow them to dispose by writing back to the PLC that Card and Pin are valid. After that I need to store all the information for the person the card and pin belonged to for reporting. I am just kinda of messing around with how I think it should work right now. I have the plc’s, card readers, and hmi’s working just threw together a quick project on development server to start bouncing around some ideas of best way to make ignition do its part.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 12:10pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/4 "2014-02-12T12:10:41Z")

</div>

The entire thing can be done with a single transaction group. In fact, that would be my personal preference. 🙂

Here’s how I’d do it:  
[attachment=0]2014-02-12\_6-49-55.png[/attachment]

[ol][li]2 PLC Tags:  
One is a string containing Card Number and PIN (i.e.: “12345,10001”). This eliminates any slow update of values that may give an incorrect response.  
The other an integer to provide a match status (1=Match, 2=No Match)  
[/li]  
[li] A Run-Always Expression to find a comma in the CARD/PIN string. This becomes the trigger for the rest:

```auto
indexOf({[.]Test/CardAndPin},",")
```

In the Triggered section:  
[/li]  
[li] Expression to extract the Card Number:

```auto
substring({[.]Test/CardAndPin},0,{[.]FindComma})
```

[li] Expression to extract the PIN:

```auto
substring({[.]Test/CardAndPin},{[.]FindComma}+1)
```

[li] SQL query to check for a match:

`select case 
   WHEN count(*)=1 THEN 1
   ELSE 2
   END
from custTable
where CardNum='{[.]Card Number}' and PIN='{[.]PIN}'`[/li]  
[li] Reset CARD/PIN string:

```auto
''
```

[li] Write to the history table:

`INSERT CustHistory (Customer, FirstName, LastName, CardNum, PIN, t_stamp)
  SELECT Customer, FirstName, LastName, CardNum, PIN, now()
  FROM CustTable
  WHERE CardNum='{[.]Card Number}' AND PIN='{[.]PIN}'`[/li][/ol]

Note that if you want to log invalid attempts by a customer, you can remove the PIN section from the WHERE clause. If you want all login attempts, remove the where clause. In these instances, I’d also add the match status to the history to tell the difference.

EDIT: Edited for grammar and spelling… and punctuation… and neatness 😉

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 12:17pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/5 "2014-02-12T12:17:14Z")

</div>

To continue, the trigger setup:  
[ol]  
[li]Check Only evaluate when values have changed  
Click Select Tags and use only the one for finding the comma.  
[/li]  
[li]Use the comma finder as the trigger  
[/li]  
[li]Set the be active\>0 / non-active\<=1. The is\>0-only condition will trigger on a -1. Weird but true.[/li][/ol]

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 7:02pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/6 "2014-02-12T19:02:33Z")

</div>

Jordan -

Thank you very much for your very detailed explanation of how you would go about doing this. Everything made great since except for one thing I did not understand that was probably the first and most simple. You suggested just using one tag as a string with the Card Number & Pin Number. Well the Card number will be stored in a data register in the PLC and the HMI will store the Pin number in another data register within the PLC. Not really sure how to combine two separate words into a string, I have never did that in the PLC’s we use???

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 7:03pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/7 "2014-02-12T19:03:19Z")

</div>

Ok. What PLC’s are you using?

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 7:07pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/8 "2014-02-12T19:07:07Z")

</div>

IDEC FC5A-D12S1E Its the Microsmart Ethernet PLC programmed with WindLDR in the Automation Organizer suite.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 7:09pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/9 "2014-02-12T19:09:04Z")

</div>

Never used them. Are you connecting via Modbus?

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 7:10pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/10 "2014-02-12T19:10:41Z")

</div>

Yea it will be modbus. I mean we use Allen Bradley and GE and Scadapack as well, but the Idec Microsmarts will be great for this application. We only use the other Plc’s for larger projects.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 7:11pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/11 "2014-02-12T19:11:57Z")

</div>

OK let me find some documentation and dig in… 🙂

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 7:40pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/12 "2014-02-12T19:40:58Z")

</div>

Only thing I have ever seen is maybe the RXD command, but that will still store the Card Number and the Pin Number to multiple data registers…

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 8:00pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/13 "2014-02-12T20:00:19Z")

</div>

Wow. I thought Omron was bad at stings. IDEC takes the prize… 😒 There would have to be a bunch of data moving around, shifted, disassembled, smacked with a hammer, and re-assembled to make a usable string over MODBUS!

I’d write a very eloquent rant about PLC manufacturers and string manipulation, but I’m trying to be good. ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")

You may be able to get away with two integers and a trigger. It’s just that if there’s a hiccup in how the data is set or reset, then robust kind of goes out the window.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 12, 2014, 8:12pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/14 "2014-02-12T20:12:09Z")

</div>

> [@cire3621](#):
>
> Only thing I have ever seen is maybe the RXD command, but that will still store the Card Number and the Pin Number to multiple data registers...

Sorry, I should explain a bit further. Most PLCs will put 2 bytes of ASCII in each data register. IDEC will put 1 byte in each data register.

So, in ASCII terms, you would never get a strings, because the fist thing it will see is a null character...

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 8:15pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/15 "2014-02-12T20:15:14Z")

</div>

Out of curiosity which PLC do you use that allows 2 sources to write two separate string values to one one spot and combine them into one larger string???

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 12, 2014, 8:18pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/16 "2014-02-12T20:18:13Z")

</div>

Im almost positive Idec writes two ascii characters to one data register…

[attachment=0]Ascii break down.JPG[/attachment]

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 13, 2014, 10:13am UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/17 "2014-02-13T10:13:35Z")

</div>

There should not be any conversion going on to keep it in ASCII. In ASCII, ‘1’=31h, ‘2’=32h, etc. To keep it ASCII in memory you should see it as 3132h, not 12h.

According to what I’m seeing, it appears that if you store the incoming stream to D10000-D49999, no conversion occurs.

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 13, 2014, 10:37pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/18 "2014-02-13T22:37:29Z")

</div>

Ok maybe I made a little progress before my card reader was reading the value of the card perfectly in the data register when i was using BCD to store it. Well I just played around with ASCII no conversion and and when i monitor the values the Scanned card bring in in DEC (W) values I get numbers but not the card number which i attached a picture of. When I change batch monitor to see what values look like in ASCII (W) values I get the card number which I also attached a picture of. Is this becoming more of a working deal? Or still not what I need to accomplish?

[attachment=0]DEC (W) Values.PNG[/attachment]  
[attachment=1]ASCII (W) Values.PNG[/attachment]

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 13, 2014, 11:25pm UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/19 "2014-02-13T23:25:02Z")

</div>

That looks a lot better! Good work!

BTW, if you can monitor in hex you can see the individual ASCII codes ![8)](https://us1.discourse-cdn.com/inductiveautomation/original/1X/587d7fe0d6822f36e81815ab06aa7164e9d2e057.gif "Cool")

As I see things the next part should be to read that ASCII string into Ignition. Once that is accomplished, two of the big hurdles are taken care of!

Also, how is the pin being entered? That’ll give me something to mull over. 😃

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [February 14, 2014, 12:54am UTC](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988/20 "2014-02-14T00:54:42Z")

</div>

It allows me to monitor any pretty much anything…so I can monitor in HEX(W) HEX(D) and pretty much all other formats…The HMI will be IDEC as well colored Multimedia touchscreens, and I just tell it where to store the PIN Number value in the PLC…IDEC actually allows you to pick if you want to store 1 or 2 bytes of ASCII per data register with the RXD command…so Ill test when I get back at the office tomorrow. Have not had the need to bring a string into Ignition thus far, so would it just be as a holding register? Also I noticed it lets you bring in BCD and found out their was a BTOA conversion which converts BCD to ASCII built in as well in IDEC…

[Next page](https://forum.inductiveautomation.com/t/should-i-use-transaction-group-for-this/7988.md?page=2)
