-->
Page 2 of 3

Re: Automated car preheating timer.

PostPosted: Sun Jan 24, 2016 4:17 am
by Jokkepappa
You are right. Thats also reason why 2H is max time for heating. After that it makes no sense keeping it heating because it won't make any difference. If your car would have battery charger connected to same electrical system as engine+indoors heater, you would have battery full of power for the first start of the day. Chargers already exists from for example Defafor their systems. Both 12V and 24V.

And well... if your car still is too cold after electrical heating you can use old way. Make bonfire wait for the fire to go out so you get the hot red coal and put that under the engine with a shovel.

With the one output, you can control one of those big industrial contactors that can handle up to 250kW of power to preheat row of cars at the same time. So when the drivers come, they have warm car/truck to drive with.

For couple of days now, since completion the first working unit. I have been thinking about how to improve it. Schedule and Oled were there already, but what more. Current sensor to detect that there is something taking the power. Used power shown on screen? Also kind of "Stay warm" sollution that if car is still connected after 2 hours of heating it would go cycles 15min on, 15min till the lead is disconnected from car keeping it somewhat warm.

Also neater GUI using .html file and javascript is in planning.

Funny thing that the thing from viewtopic.php?f=45&t=7767 kinda makes making own pcb and populating it kinda useless (even tho it's more fun). With that you just need to connect couple mains cables and you are done.

Re: Automated car preheating timer.

PostPosted: Sun Jan 24, 2016 7:35 pm
by Jokkepappa
Update of the project for the community before i make blogpost.
Installed 0.93" oled display to the case today. Also created refresh free GUI using .html stored on flash and AJAX from pulling the data.

Code will be coming when i get to pc again. Meanwhile teaser pic.

Image

Re: Automated car preheating timer.

PostPosted: Mon Jan 25, 2016 6:28 am
by viscomjim
Jokkepappa, very nice project. I like the packaging too! Like Mike says, amazing what can be done in BASIC. Keep up the good work.

Re: Automated car preheating timer.

PostPosted: Mon Jan 25, 2016 9:16 am
by Jokkepappa
Thanks. As promised time for the code. Also made blogpost of with some more pictures you can read Here

GUI.html (used bit modified code from this: viewtopic.php?f=40&t=7162)
Code: Select all<html>
<head>
<title>L&auml;mmityksen ajastin</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="/file?file=ulkoasu.css">

<script type="text/javascript">

var get = new XMLHttpRequest();
var responsed = "Loading";


setInterval(function()
{
wGet("/input?");

getResponse();
var responsedata = responsed.split("|");
var hours = responsedata[2] / 60 / 60;
var minutes = responsedata[2] / 60 % 60;
var seconds = responsedata[2] % 60;
minutes = parseInt(minutes);
seconds = parseInt(seconds);

if(minutes < 10){minutes = "0" + minutes;}
if(seconds < 10){seconds = "0" + seconds;}
var timeLeft = parseInt(hours) + ":" + minutes + ":" + seconds;

if(responsedata[2] == 0){timeLeft = 0;}

if(responsedata[1] == "On" || responsedata[1] == "Off"){
document.getElementById("data").innerHTML = "Heater: " + responsedata[1] + "<br>Time Left: " + timeLeft;
 }
 
}, 2500)

 
function wGet(data)
{
   get.open("GET", data, true);
   get.onreadystatechange = getResponse;
   get.send(null);

}

function getResponse() {

   if (get.readyState == 4 && get.status == 200)
   {
      responsed = get.responseText;

   }

}

function setHeating()
{
var valittuAika = document.getElementById("Aika").selectedIndex;
switch(valittuAika)
{
   case 0:
      wGet('/msg?addTime=7200')
      break;
   case 1:
      wGet('/msg?addTime=5400')
      break;
   case 2:
      wGet('/msg?addTime=3600')
      break;
   case 3:
      wGet('/msg?addTime=1800')
      break;
}

}

function setElements()
{
document.getElementById("turnOnButton").style.width = "250px";
}

</script>

</head>
<body onLoad="setElements()">
<center><b>
<p id="data">Loading</p>
<select id="Aika">
<option SELECTED>2H
<option>1H 30Min
<option>1H
<option>30Min
</select>
<button onClick="setHeating()" id="turnOnButton">Turn On</button><br>
<button onClick="wGet('/msg?addTime=0')" >Off</button><br>
</center></b>
</body>
<html>


basic code:
Code: Select allmemclear
cls
oledcls
state = Off
po 13, 0
po 14, 0
connect "Retejo Secondary" "gfdsaasdfg" "192.168.1.102" "192.168.1.1" "255.255.255.0"
msgbranch [messageHandler]
heatingTime = 0
heatingTimeMin = 0
humanTime = 0
scheduled = 0
timer 1000, [timerSec]
wprint |<meta http-equiv='refresh' content='11110;URL=/file?file=GUI.html'></head>|
wprint "|"
wprint htmlvar(state)
wprint "|"
wprint htmlvar(heatingTime)
wprint "|"
oledprint "Heater: " 0 0
oledprint "Time left: " 0 1
oledprint ip() 0 6
wait

[messageHandler]
let messageToReturn = state & "|"
let messageToReturn = messageToReturn & heatingTime
msgreturn messageToReturn
msgget "addTime" timeAddMessage
if timeAddMessage > 0 then goto [turnOn] else goto [turnOff]
wait

[turnOn]
po 13, 1
po 14, 1
heatingTime = timeAddMessage
oledprint "On " 8 0
state = On
wait

[turnOff]
po 13, 0
po 14, 0
state = Off
oledprint "Off" 8 0
heatingTime = 0
wait

[phyButton]
if io(pi,12) = 0 then wait
plusheatingTime = heatingTime + 1800
if plusheatingTime < 7200 then timeAddMessage = plusheatingTime
if plusheatingTime < 7200 then goto [addTime]
if plusheatingTime > 7200 then goto [turnOff]
wait

[addTime]
heatingTime = heatingTime + 1800
goto [turnOn]
wait

[timerSec]
plusheatingTime = 0
heatingTime = heatingTime - 1
heatingTimeMin = heatingTime / 60
if heatingTime > 3600 then heatingTimeMin = heatingTimeMin - 60
let heatingTimeMin = left(heatingTimeMin,2)
let heatingTimeMin = replace(heatingTimeMin,".","")
if heatingTime > 3600 then humanTime = "1h "
if heatingTime > 3600 then humanTime = humanTime & heatingTimeMin
if heatingTime > 3600 then humanTime = humanTime & "min"
if heatingTimeMin <= 0 then heatingTimeMin = 0
if heatingTime < 3600 then humanTime = heatingTimeMin & "min"
gosub [checkTime]
if io(pi,12) = 1 then goto [phyButton]
if heatingTime <= 0 then goto [turnOff]
wait

[checkTime]
if pasttime <> humanTime then gosub [updateOled]
return

[updateOled]
oledprint "                  " 0 2
oledprint humanTime 0 2
pasttime = humanTime
return


EDIT:
Here you can find design files and everything else in a zip package:
http://jokenkosto.blogspot.fi/2016/01/d ... timer.html