// Coproc_test1.osc // // Floating-point co-processor test routines for the OOPIC. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Contributors: // Neil Durant // // // Sends the COMMCK command to the PAK-II, and tests to see if // hex 2B is returned, which indicates success. // It then tests the calculation 1.234 + 5.678. // Output is to an LCD device. The program should be adjusted to suit // your own display setup etc. // User classes - adjust these paths to suit your own setup oUserClass pak2 = new oUserClass("F:\Projects\Home\Robot\BK\Coproc_Board\Libs\oNMD_Coproc.osc"); oUserClass lcd = new oUserClass("F:\Projects\Home\Robot\BK\OOPIC_Main\Libs\oNMD_LCD.osc"); byte byteX; Sub void main(void) { lcd.ClearScreen; lcd.lcd.String = "Sending COMMCK"; pak2.Reset; OOPIC.Delay = 100; //////////////////////////////////////////////////////////////////////////////// // COMMCK test //////////////////////////////////////////////////////////////////////////////// pak2.COMMCK; pak2.ReadByte; lcd.ClearScreen; if(pak2.status == 43) { lcd.lcd.String = "COMMCK passed"; } else { lcd.lcd.String = "COMMCK failed"; lcd.MoveTo(1, 0); lcd.lcd.String = "Returned: "; lcd.lcd.String = Str$(pak2.byteX); } OOPIC.Delay = 100; //////////////////////////////////////////////////////////////////////////////// // Add test //////////////////////////////////////////////////////////////////////////////// // Add two values, and test return value // We test 1.234 + 5.678 = 6.912 // 1.234 = hex 7F1DF3B6 pak2.LoadX(&H7F, &H1D, &HF3, &HB6); // 5.678 = hex 8135B22D pak2.LoadY(&H81, &H35, &HB2, &H2D); pak2.Add; pak2.ReadX; // 6.912 = hex 815D2F1A // hex 1A = 26 // hex 2F = 47 // hex 5D = 93 // hex 81 = 129 lcd.ClearScreen; if((pak2.f0 == 26) & (pak2.f1 == 47) & (pak2.f2 == 93) & (pak2.f3 == 129)) { lcd.lcd.String = "Add test passed"; OOPIC.Delay = 100; } else { lcd.lcd.String = "Add test failed"; lcd.MoveTo(1, 0); lcd.lcd.String = "f0-f3 follow..."; OOPIC.Delay = 100; DisplayFNumbers; OOPIC.Delay = 200; } //////////////////////////////////////////////////////////////////////////////// // Negative integer load test //////////////////////////////////////////////////////////////////////////////// // Load a negative int, convert to float, and check result pak2.wordX = -10; pak2.LoadXFromWord; pak2.Float; pak2.ReadX; // -10 = 82 A0 00 00 lcd.ClearScreen; if((pak2.f0 == 0) & (pak2.f1 == 0) & (pak2.f2 == &HA0) & (pak2.f3 == &H82)) { lcd.lcd.String = "Neg load passed"; OOPIC.Delay = 100; } else { lcd.lcd.String = "Neg load failed"; lcd.MoveTo(1, 0); lcd.lcd.String = "f0-f3 follow..."; OOPIC.Delay = 100; DisplayFNumbers; OOPIC.Delay = 200; } //////////////////////////////////////////////////////////////////////////////// // Negative integer read test //////////////////////////////////////////////////////////////////////////////// // Load a negative int, convert to float, and check result pak2.LoadX(&H82, &HA0, 0, 0); // -10 pak2.Int; pak2.ReadXAsWord; lcd.ClearScreen; if(pak2.wordX == -10) { lcd.lcd.String = "Neg read passed"; OOPIC.Delay = 100; } else { lcd.lcd.String = "Neg read failed"; lcd.MoveTo(1, 0); lcd.lcd.String = "Returned:"; lcd.lcd.String = Str$(pak2.wordX); OOPIC.Delay = 200; } } Sub void DisplayFNumbers(void) { lcd.ClearScreen; lcd.lcd.String = Str$(pak2.f0); lcd.MoveTo(0, 8); lcd.lcd.String = Str$(pak2.f1); lcd.MoveTo(1, 0); lcd.lcd.String = Str$(pak2.f2); lcd.MoveTo(1, 8); lcd.lcd.String = Str$(pak2.f3); } // End of Coproc_test1.osc