3/5/2019 1:49 AM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hi, I am using nodered to commnunicate with LOGO8 and i woud like to know if there is a way to change the Hour and Minute in the Weekly timer Block ? I have mapped the parameter On Time and on the nodered side i can write in the VM , the value changes but the format does not match. Any possible help ? Regards, MD  
Last edited by: Jen_Moderator at: 3/5/2019 7:39:23 AMNew subject after splitting 

3/5/2019 4:46 AM  
Joined: 12/18/2014 Last visit: 8/19/2019 Posts: 14864 Rating: (1548) 
Hello AutoGen_5957274, the problem is the fact that the on / off times of a weekly timer in the LOGO! BCD encoded.I do not know IoT2000. Therefore, I do not know if it is possible to perform a conversion from decimal to BCD on IoT. Therefore, it would be better if the question is asked in the IoT forum. I will ask the moderation to postpone your question as a separate topic in the IoT conference. 
3/5/2019 8:47 AM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
Additional information, if you have a time 12:34h, this must be the hexadecimal representation Hex=1234, the decimal presentation Dec=4660. You can calculate the decimal representation as follows: 4096 x tens of hours + 256 x ones of hours + 16 x tens of minutes + 1 x ones of minutes For the example 4096x1+256x2+16x3+4=4660 If you have the basic operations +  x / mod div, it would be easy to calculate the desired time. Regards, Scorp 
3/5/2019 8:52 PM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hello Scorp, Your adicional information it´s correct i have tested and it works. I have still no idea how to implment your solution. . I would like to set the time of LOGO´s block in nodered dashboard , any ideas to solve this requets are welcome. Thanks, Regards, MD 
3/5/2019 10:38 PM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
Sorry, i have not used nodered until now. Is it right, you use nodered with Siemens IOT2040 ? Then it should be the possible to write a c++ program or something else ? Where are the values of your timer you want to write to the Logo ? Maybe other people can help, but they also need more details. Regards, Scorp 
3/6/2019 7:22 AM  
Joined: 4/28/2015 Last visit: 8/2/2019 Posts: 1151 Rating: (183)

Hi, can you please provide your current flow? Then I will have a look how to add the conversion to your flow. Best regards! 
This contribution was helpful to2 thankful Users 
3/6/2019 2:34 PM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Attached simple flow i am using for testing. Thanks Regards, MD AttachmentConvertHexToDecimal.txt (15 Downloads) 
3/8/2019 10:34 AM  
Joined: 4/28/2015 Last visit: 8/2/2019 Posts: 1151 Rating: (183)

Hi, I cannot find any code which can "translate" Hex/Dec into BCD. But there is a node: https://flows.nodered.org/node/noderedcontribbinary I will try that.. Not sure yet if this is the right functionality you are searching for. Best regards! 
3/9/2019 12:07 AM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hello Scorp, Your information about converting from Hex to Decimal has been very useful . I would llke to ask if you could show how to calculate from decimal to hex representation ? Thank you ! Best Regards, MD 
3/9/2019 12:19 AM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hi, I have already tried the node you mention but does not work. I think the solution could be use a function block node in nodered to write a script to convert the input Hex to output Decimal based on the calculation Scorp has described. Regards MD 
3/9/2019 7:07 AM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
I don't know the syntax of Java script, maybe it is similar to C++ Let us define following variables: Declare variables as needed by Java script, then calculate as follows: OM =EntryTime % 10; // extracting the 4 from 1234 Maybe anyone know, how to insert such operations in Java script with the right syntax. The "%" is the modulo function to get the rest by deviding. If you have another entry format e.g. separated hours and minutes, this is no problem. Just declare other variables and use the same principle. Regards, Scorp

3/11/2019 12:05 PM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hi Scorp, Converting from Hex to decimal is well understood. How would you make the opposite , convert from decimal do Hex ? How would you write the script in C++ ? Thanks, M D 
3/11/2019 2:23 PM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
I have described the converter from dec to hex in my last entry. You have a decimal value 1234, which should be the time 12:34h and get the decimal value 4660, which should be the hexadecimal representation $1234. If you mean anything else, then describe clearly. I have asked, from where the value comes. Do you have one or two entry fields as variables ? Regards, Scorp 
3/12/2019 7:31 AM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
Let's try another way. I would like to have 2 entry fields, therefore we define following variables: EH = entry hours in decimal EM = entry minutes in decimal TH = tens of hours in decimal OH = ones of hours in decimal TM = tens of minutes in decimal OM = ones of minutes in decimal LT = Logo time in hexadecimal representation AUX = auxiliary variable First way, EH and EM is given, LT has to be calculated OH = EH % 10; TH = (EHOH) / 10; OM = EM % 10; TM = (EMOM / 10; LT = 4096 * TH + 256 * OH + 16 * TM + 1 * OM; Second way, LT is given, EH and EM has to be calculated OM = LT % 16; AUX = (LT  OM) / 16; TM = AUX % 16; AUX = (AUX  TM) / 16; OH = AUX % 16; TH = (AUX  OH) / 16; EH = TH * 10 + OH; EM = TM * 10 + OM; Regards, Scorp 
This contribution was helpful to1 thankful Users 
3/12/2019 4:01 PM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hi Scorp, Sorry for not being clear. Thank you very much for such complete explanation. Now i will try find a way to " translate" your code to Java script. Regards, MD 
3/12/2019 4:47 PM  
Joined: 2/22/2008 Last visit: 8/18/2019 Posts: 1054 Rating: (72) 
The mathematical operations of my example are available in Java and similar in C++, but i don't know, how to insert in node red dashboard or the right syntax. I have never programmed Java either node red dashboard until now. Therefore you only can see the mathematical principles. Regards, Scorp 
3/22/2019 1:01 PM  
Joined: 4/4/2016 Last visit: 8/9/2019 Posts: 39 Rating: (1) 
Hi Scorp, Based in your explanation find in attachment nodered node function to convert decimal to Hex > Hour representation. Change var newMsg = { payload: EM} for getting Hex > minutes. Regards, Thank you for your help. MD AttachmentDecToHexHour.txt (5 Downloads) 
This contribution was helpful to1 thankful Users 
Follow us on