<div dir="auto">Forgot to add, you'll need to do val1*256+val2 at the other end to reconstruct your 16-bit value, you may also want to add some sync characters before/after each value pair</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 26, 2020, 12:08 PM Marshland Engineering <<a href="mailto:marshland@marshland.co.nz">marshland@marshland.co.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the replies. Some useful information. <br>
<br>
Basically I'm updating my Dyno hardware/software to include Drum and motor<br>
RPM, 02, Cylinder head and Exhaust Gas temperatures. <br>
<br>
All the figures will be +ve between 0 and 65535 and at sample rate of 10 hz.<br>
Not rocket science but working on the Atmega is my equivalent of a Wasjig. <br>
<br>
I think I have it all sorted except for itoa which is int and not unsigned<br>
int. <br>
<br>
Can I modify my c libraries to make it unsigned or maybe just write my own<br>
function. <br>
<br>
Cheers Wallace.<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Thanking you<br>
Wallace Weideman<br>
Marshland Engineering<br>
704 Marshland Road<br>
Styx<br>
Christchurch<br>
03 3237449<br>
<a href="http://www.marshland.co.nz" rel="noreferrer noreferrer" target="_blank">www.marshland.co.nz</a><br>
<br>
<br>
<br>
On 25/10/2020 at 3:01 p.m., <a href="mailto:chchrobotics-request@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics-request@lists.ourshack.com</a> wrote:<br>
>Send Chchrobotics mailing list submissions to<br>
> <a href="mailto:chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics@lists.ourshack.com</a><br>
><br>
>To subscribe or unsubscribe via the World Wide Web, visit<br>
> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>or, via email, send a message with subject or body 'help' to<br>
> <a href="mailto:chchrobotics-request@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics-request@lists.ourshack.com</a><br>
><br>
>You can reach the person managing the list at<br>
> <a href="mailto:chchrobotics-owner@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics-owner@lists.ourshack.com</a><br>
><br>
>When replying, please edit your Subject line so it is more specific<br>
>than "Re: Contents of Chchrobotics digest..."<br>
><br>
><br>
>Today's Topics:<br>
><br>
> 1. Mantraps, security etc. (Mark Atherton)<br>
> 2. Re: High voltage batteries and electrolytic capacitors<br>
> (Andy Gardner)<br>
> 3. int > ascii > int (Bevin Brett)<br>
><br>
><br>
>----------------------------------------------------------------------<br>
><br>
>Message: 1<br>
>Date: Sun, 25 Oct 2020 13:41:43 +1300<br>
>From: Mark Atherton <<a href="mailto:markaren1@xtra.co.nz" target="_blank" rel="noreferrer">markaren1@xtra.co.nz</a>><br>
>To: <a href="mailto:chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics@lists.ourshack.com</a><br>
>Subject: [chbot] Mantraps, security etc.<br>
>Message-ID: <<a href="mailto:35e4c553-24d2-4370-8761-0fdd037086a4@xtra.co.nz" target="_blank" rel="noreferrer">35e4c553-24d2-4370-8761-0fdd037086a4@xtra.co.nz</a>><br>
>Content-Type: text/plain; charset=utf-8; format=flowed<br>
><br>
>I doubt if an electrified razor-wire fence would be considered any form <br>
>of a trap if you had suitable warnings. Take a look at "Holland's Suzuki <br>
>Cars, 4 Shakespeare Road, Waltham". From street-view the electrification <br>
>signs on the fence are visible as yellow rectangles.<br>
><br>
>If I were interested in tightening up security of a property in an <br>
>enthusiastic manner, I would talk to the police first. Possibly by <br>
>inviting them around to advise.<br>
><br>
>What was the result of the burglary ?<br>
><br>
>-mark<br>
><br>
><br>
><br>
><br>
>On 25/10/2020 11:40 AM, Henri Shustak wrote:<br>
>> Hello,<br>
>> <br>
>> Thank you for the reply. I am wondering would this apply to something like<br>
barbed wire to make getting in/out of a property more difficult? If someone<br>
got injured by trying to get over it?<br>
>> <br>
>> Just had a problem with a drone overhead and then a week later (possibly<br>
unrelated) someone in a group entering the property by climbing the fence.<br>
Hence my questions.<br>
>> <br>
>> Your information has been super useful.<br>
>> <br>
>> Sorry to hijack this thread.<br>
>> <br>
>> Henri<br>
>> <br>
>>> On 25/10/2020, at 11:34 AM, Mark Atherton <<a href="mailto:markaren1@xtra.co.nz" target="_blank" rel="noreferrer">markaren1@xtra.co.nz</a>> wrote:<br>
>>><br>
>>> 202 Setting traps, etc<br>
>>><br>
>>> (1) Every one is liable to imprisonment for a term not exceeding 5 years<br>
who, with intent to injure, or with reckless disregard for the safety of<br>
others, sets or places or causes to be set or placed any trap or device that<br>
is likely to injure any person.<br>
>>><br>
>>> (2) Every one is liable to imprisonment for a term not exceeding 3 years<br>
who, being in occupation or possession of any place where any such trap or<br>
device has been set or placed, knowingly and wilfully permits it to remain<br>
there in such a condition that any person is likely to be injured by it.<br>
>>><br>
>>> <a href="http://www.legislation.govt.nz/act/public/1961/0043/137.0/DLM329707.html" rel="noreferrer noreferrer" target="_blank">http://www.legislation.govt.nz/act/public/1961/0043/137.0/DLM329707.html</a><br>
>>><br>
>>><br>
>>> On 25/10/2020 11:30 AM, Henri Shustak wrote:<br>
>>>> Hi I am actually looking right now at what these laws are if anyone can<br>
explain in simple terms that would be great. Basically, are you responsible<br>
for trespassing people injuring themselves on your property? Any links would<br>
be welcomed. I have not had any luck finding the details or even an overview.<br>
>>>>> Damn that mantrap law.<br>
>>>>><br>
>>>>> On 5/10/20 7:37 pm, Mark Atherton wrote:<br>
>>>>>> I was about to express concern about the type of insulator that your<br>
coffee table is constructed from (mica ?), but on second thoughts I might be<br>
better off asking if you charge the unit before going to bed at night. Might<br>
be good at catching burglars :)<br>
>>><br>
><br>
><br>
><br>
>------------------------------<br>
><br>
>Message: 2<br>
>Date: Sun, 25 Oct 2020 14:33:35 +1300<br>
>From: Andy Gardner <<a href="mailto:ceo@andygardner.com" target="_blank" rel="noreferrer">ceo@andygardner.com</a>><br>
>To: <a href="mailto:chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics@lists.ourshack.com</a><br>
>Subject: Re: [chbot] High voltage batteries and electrolytic<br>
> capacitors<br>
>Message-ID: <<a href="mailto:9ed093b6-4ba0-20c5-7a5e-b9a876df1b25@andygardner.com" target="_blank" rel="noreferrer">9ed093b6-4ba0-20c5-7a5e-b9a876df1b25@andygardner.com</a>><br>
>Content-Type: text/plain; charset=utf-8; format=flowed<br>
><br>
><br>
><a href="https://ccc.govt.nz/consents-and-licences/resource-consents/residential-and-housing/property" rel="noreferrer noreferrer" target="_blank">https://ccc.govt.nz/consents-and-licences/resource-consents/residential-and-housing/property</a><br>
><br>
>####<br>
><br>
>Barbed wire or razor wire fences<br>
><br>
>The Council Public Places Bylaw 2018 states that barbed wire, razor wire or<br>
electrified wire may not be used within one metre of any property boundary<br>
adjoining any public place, unless the wire is at a height of 2.5m or more<br>
above ground level, or the public place is in a rural area. Internal boundary<br>
fences are covered by the Fencing Act 1978.<br>
><br>
>If the height of the fence is over 2.5m, a resource consent and a building<br>
consent will be required. Therefore it is recommended that you contact the the<br>
Duty Planner on 03 941 8999 if your proposed fence is over this height.<br>
><br>
>####<br>
><br>
><br>
><br>
>On 25/10/20 11:40 am, Henri Shustak wrote:<br>
>> Hello,<br>
>> <br>
>> Thank you for the reply. I am wondering would this apply to something like<br>
barbed wire to make getting in/out of a property more difficult? If someone<br>
got injured by trying to get over it?<br>
>> <br>
>> Just had a problem with a drone overhead and then a week later (possibly<br>
unrelated) someone in a group entering the property by climbing the fence.<br>
Hence my questions.<br>
>> <br>
>> Your information has been super useful.<br>
>> <br>
>> Sorry to hijack this thread.<br>
>> <br>
>> Henri<br>
>> <br>
>>> On 25/10/2020, at 11:34 AM, Mark Atherton <<a href="mailto:markaren1@xtra.co.nz" target="_blank" rel="noreferrer">markaren1@xtra.co.nz</a>> wrote:<br>
>>><br>
>>> 202 Setting traps, etc<br>
>>><br>
>>> (1) Every one is liable to imprisonment for a term not exceeding 5 years<br>
who, with intent to injure, or with reckless disregard for the safety of<br>
others, sets or places or causes to be set or placed any trap or device that<br>
is likely to injure any person.<br>
>>><br>
>>> (2) Every one is liable to imprisonment for a term not exceeding 3 years<br>
who, being in occupation or possession of any place where any such trap or<br>
device has been set or placed, knowingly and wilfully permits it to remain<br>
there in such a condition that any person is likely to be injured by it.<br>
>>><br>
>>> <a href="http://www.legislation.govt.nz/act/public/1961/0043/137.0/DLM329707.html" rel="noreferrer noreferrer" target="_blank">http://www.legislation.govt.nz/act/public/1961/0043/137.0/DLM329707.html</a><br>
>>><br>
>>><br>
>>> On 25/10/2020 11:30 AM, Henri Shustak wrote:<br>
>>>> Hi I am actually looking right now at what these laws are if anyone can<br>
explain in simple terms that would be great. Basically, are you responsible<br>
for trespassing people injuring themselves on your property? Any links would<br>
be welcomed. I have not had any luck finding the details or even an overview.<br>
>>>>> Damn that mantrap law.<br>
>>>>><br>
>>>>> On 5/10/20 7:37 pm, Mark Atherton wrote:<br>
>>>>>> I was about to express concern about the type of insulator that your<br>
coffee table is constructed from (mica ?), but on second thoughts I might be<br>
better off asking if you charge the unit before going to bed at night. Might<br>
be good at catching burglars :)<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">Chchrobotics@lists.ourshack.com</a><br>
>>> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>>> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>>> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer noreferrer" target="_blank">http://kiwibots.org</a> for venue,<br>
directions and dates.<br>
>>> When replying, please edit your Subject line to reflect new subjects.<br>
>> <br>
>> <br>
>> _______________________________________________<br>
>> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">Chchrobotics@lists.ourshack.com</a><br>
>> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer noreferrer" target="_blank">http://kiwibots.org</a> for venue,<br>
directions and dates.<br>
>> When replying, please edit your Subject line to reflect new subjects.<br>
>> <br>
><br>
><br>
><br>
>------------------------------<br>
><br>
>Message: 3<br>
>Date: Sun, 25 Oct 2020 02:00:55 +0000<br>
>From: Bevin Brett <<a href="mailto:bevin_brett@hotmail.com" target="_blank" rel="noreferrer">bevin_brett@hotmail.com</a>><br>
>To: "<a href="mailto:chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics@lists.ourshack.com</a>"<br>
> <<a href="mailto:chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">chchrobotics@lists.ourshack.com</a>><br>
>Subject: [chbot] int > ascii > int<br>
>Message-ID:<br>
> <<a href="mailto:MW3PR12MB4491AFB7B04BA98898DD064A93180@MW3PR12MB4491.namprd12.prod.outlook.com" target="_blank" rel="noreferrer">MW3PR12MB4491AFB7B04BA98898DD064A93180@MW3PR12MB4491.namprd12.prod.outlook.com</a>><br>
> <br>
>Content-Type: text/plain; charset="iso-8859-1"<br>
><br>
>Ok, assuming you are NOT going to use some standard library, here are the<br>
issues and some code<br>
><br>
>Let us first discuss getting the character string from one machine to the<br>
other.<br>
>Either (a) it is fixed length, or (b) you put a size on the beginning, or<br>
(c) you put a flag at the end<br>
>Fixed length is easiest, and least efficient.<br>
>Size is only best if the length is very long - its not going to be here.<br>
>So instead we need a flag at the end. Lets do that - we will discuss how in<br>
a minute.<br>
><br>
>So assuming that the characters arrive one at a time you get some receiver<br>
code that looks like<br>
><br>
> int i = 0;<br>
> while (getNextChar(&c)) {<br>
> adjust i using c<br>
> }<br>
><br>
>Next problem. What characters can you send. Can you send ANY (0x00..0xff)<br>
character, or does the h/w and s/e connecting the two ends stop you from using<br>
NUL (0x00)? CR? LF? Ctrl-S? Ctrl-Q? others?. Let's assume that you can<br>
only send printable chars ' '..'~'.<br>
><br>
> char firstSendableChar = ' ';<br>
> char lastSendableChar = '~';<br>
> int nSendableChars = ((int)(lastSendableChar) - (int)(lastSendableChar)) +<br>
1;<br>
><br>
>Now the basic idea, we are going to have to improve it, is to do this at the<br>
transmitting end<br>
><br>
> int val = <the number to send><br>
><br>
> while (val > 0) {<br>
> char toSend = val % nSendableChars; // these two lines are the<br>
crux of the solution<br>
> val = val / nSendableChars;<br>
> send((char)(toSend + firstSendableChar ))<br>
> }<br>
><br>
><br>
> int i = 0;<br>
> while (getNextChar(&c)) {<br>
> i = i*nSendableChars + (c - firstSendableChar);<br>
> }<br>
><br>
>Okay, so now we only have two problems. (a) negative numbers, and (b)<br>
knowing when to stop.<br>
><br>
>You could just do the above using unsigned int, and use<br>
> unsigned int unsignedIntermediate = (unsigned int)(input);<br>
> ...<br>
> send and receive<br>
> ...<br>
> int output = (int) unsignedIntermediate;<br>
>and the only problem with that is -small is a very long this way.<br>
><br>
>A better approach is to send the sign bit similarly to sending the count.<br>
><br>
>The second problem is that there is no positive number corresponding to the<br>
most negative number, so you can't just do<br>
> int sign = (value > 0);<br>
> if (sign) value = -value;<br>
>Instead you have to do<br>
> if (!sign) value = -value;<br>
><br>
>Now the above loop using % and / requires understanding how those operations<br>
work with -ve numbers.<br>
><br>
>How to send the sign and end-of-number bits? One thing to do place them both<br>
in the last character. To do this,<br>
>reduce the<br>
><br>
> int nDigitChars = nSendableChars / 2;<br>
><br>
>Now we can code the above loop<br>
><br>
> while (val > 0) {<br>
> int nextVal = val / nDigitChars ;<br>
> char toSend = val % nDigitChars ; // these two lines are the crux<br>
of the solution<br>
> if (nextVal == 0) toSend += nDigitChars ;<br>
> val = nextVal ;<br>
> send((char)(toSend + firstSendableChar ))<br>
> }<br>
><br>
>and the receive loop<br>
><br>
> int i = 0;<br>
> while (getNextChar(&c)) {<br>
> int atEnd = (c >= nDigitChars );<br>
> if (atEnd) c -= nDigitChars ;<br>
> i = i*nDigitChars + (c - firstSendableChar);<br>
> if (atEnd) break;<br>
> }<br>
><br>
>I'll leave it as an exercise to the reader to place the sign bit in the last<br>
sent character.<br>
><br>
>I'm not sure the complexity of the above is worth it.<br>
><br>
>Those % and / are expensive. There are faster ways than the above - I spent<br>
a few months working on the integer to/from string in the 1990's because<br>
believe it or not it is an important operation in telephone systems.<br>
><br>
>/Bevin<br>
>-------------- next part --------------<br>
>An HTML attachment was scrubbed...<br>
>URL:<br>
<<a href="http://lists.ourshack.com/pipermail/chchrobotics/attachments/20201025/a75132ba/attachment.html" rel="noreferrer noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/attachments/20201025/a75132ba/attachment.html</a>><br>
><br>
>------------------------------<br>
><br>
>Subject: Digest Footer<br>
><br>
>_______________________________________________<br>
>Chchrobotics mailing list<br>
><a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">Chchrobotics@lists.ourshack.com</a><br>
><a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer noreferrer" target="_blank">http://kiwibots.org</a> for venue,<br>
directions and dates.<br>
>Please edit your Subject line to reflect new subjects. <br>
><br>
>------------------------------<br>
><br>
>End of Chchrobotics Digest, Vol 157, Issue 22<br>
>*********************************************<br>
<br>
<br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank" rel="noreferrer">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div>